mongodb - Error with count of docs where criteria applies to embedded array -
i have mongodb collection called assignments, have multiple bids (embedded arrays). when 1 of bids set accepted:true, considered accepted_bid.
i want function returns docs (or count of docs) have 1 bid out of many (embedded arrays), owned logged in user.
the next not work. i'm looking have {{stats.count}} in html file.
template.dashboard.stats = function() { homecoming assignments.find({completed:true}, { transform: function(doc) { if(doc.bids) { var accepted_bid = _(doc.bids).findwhere({owner:meteor.userid(),accepted:true}); doc.bid = accepted_bid; } homecoming doc; } }); };
im not sure if work returns count:
template.dashboard.helpers({ stats: function() { var assignments = assignments.find({ completed: true }, { transform: function(doc) { if (doc.bids) { var accepted_bid = _(doc.bids).findwhere({ owner: meteor.userid(), accepted: true }); if(accepted_bid) doc.bid = accepted_bid; } homecoming doc; } }).fetch(); homecoming _(assignments).chain().pluck("bid").compact().value().length; } });
it can used {{stats}}
mongodb meteor
No comments:
Post a Comment