I have 2 collections - competition and product. Competition contains the product objectID
and product contains competition_status
.
What I'm trying to do is ONLY display the competitions whose product has a competition_status
of "Complete" or "Current".
I've implemented this, however, I am also seeing the competitions that had a "Pending" status, just the product objects is null for these two. I somehow need these competitions removed from the competitions object that is outputted.
api.mongo.competition.find(filter)
.populate('product', 'name competition_status', { competition_status: { $in: ['Complete', 'Current'] } })
.exec(
function(err, competitions) {
if(err) {
next(err, {});
return;
}
next(err, competitions);
});