javascript - Transform data before rendering it to template in meteor -
i want return single document fields joined together. is, result follows
{ _id: "someid", name: "odin", profile: { game: { _id: "gameid", name: "world of warcraft" } } }
i have route controller simple.
usercontroller = routecontroller.extend({ waiton: function () { return meteor.subscribe('users'); }, showallusers: function () { this.render('userlist', { data: meteor.users.find() }) } });
i've tried changing data so:
this.render('userlist', { data: meteor.users.find().map(function (doc) { doc.profile.game = games.findone(); return doc; }) });
however, not have intended effect of adding "game" user. (and yes, games.findone()
has result)
how can transform results of cursor in meteor , iron:router?
try defining data
function can dynamically re-executed when needed.
usercontroller = routecontroller.extend({ waiton: function () { return meteor.subscribe('users'); }, showallusers: function () { this.render('userlist', { data: function(){ return meteor.users.find().map(function (doc) { doc.profile.game = games.findone(); return doc; }); } }); } });
Comments
Post a Comment