How to publish a view/transform of a collection in Meteor?
I have made a collection
var Words = new Meteor.Collection("words");
and published it:
Meteor.publish("words", function() {
return Words.find();
});
so that I can access it on the client. Problem is, this collection is
going to get very large and I just want to publish a transform of it. For
example, let's say I want to publish a summary called "num words by
length", which is an array of ints, where the index is the length of a
word and the item is the number of words of that length. So
wordsByLength[5] = 12;
means that there are 12 words of length 5. In SQL terms, it's a simple
GROUP BY/COUNT over the original data set. I'm trying to make a template
on the client that will say something like
You have N words of length X
for each length. My question boils down to "I have my data in form A, and
I want to publish a transformed version, B".