Answer the question
In order to leave comments, you need to log in
How to rewrite mongo query without $facet?
const query = {
$aggregate: [
{ $match: { active: { $ne: false } } },
{
$facet: {
buyers: [{ $match: { userType: 'media_buyer' } }, { $project: { _id: 1, fullName: 1 } }],
managers: [{ $match: { userType: 'account_manager' } }, { $project: { _id: 1, fullName: 1 } }],
campaignManagers: [
{ $match: { userType: 'campaign_manager' } },
{ $project: { _id: 1, fullName: 1 } },
],
},
},
],
};
return User.get(query).then(r => r[0]);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question