just quick question.
i have 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; < arraylength; i++){ var tags = results[i]; sub.added('posts', math.random(), tags); } sub.ready(); }); why need have additional loop store data in collection posts.
for(var i=0; < arraylength; i++){ var tags = results[i]; sub.added('posts', math.random(), tags); } sub.ready(); if return result without including loop sub.added array of non-cursor error on client namespace.
in case ,
this code
sub.added('posts', math.random(), tags); we ddp document id = math.random() fields = tags added posts collection. ddp used bond client , server , should transfer client when subscribe (client apps).
an illustration of meteor platform: 
ddp default package once meteor app create.
Comments
Post a Comment