Hi, just a quick question.
i have an example of publication using aggregation.
Meteor.publish('tags', function(tag){
var sub = this;
var pipeline = [
{$project: {tags:1, author: 1, title:1, permalink:1 }},
{$unwind:"$tags"},
{$match: {"tags": tag}}];
var results = Posts.aggregate(pipeline);
var arrayLength = results.length;
for(var i=0; i < arrayLength; i++){
var tags = results[i];
sub.added('posts', Math.random(), tags);
}
sub.ready();
});
why do i need to have an additional loop to store a data in the collection posts
.
for(var i=0; i < arrayLength; i++){
var tags = results[i];
sub.added('posts', Math.random(), tags);
}
sub.ready();