[ { "$lookup": { "from": "participant", "localField": "participantId", "foreignField": "_id", "as": "participants" } }, { "$unwind": { "path": "$participants", "preserveNullAndEmptyArrays": true } }, { "$lookup": { "from": "subscription", "localField": "participantId", "foreignField": "userId", "as": "subscriptions" } }, { "$unwind": { "path": "$subscriptions", "preserveNullAndEmptyArrays": true } }, { "$lookup": { "from": "subscriptionPlan", "localField": "subscriptions.planId", "foreignField": "_id", "as": "subscriptionPlans" } }, { "$unwind": { "path": "$subscriptionPlans", "preserveNullAndEmptyArrays": true } }, { "$match": { "nutritionistID": { "$oid": "64782249defe1c75d7689cbd" } } }, { "$match": { "subscriptions.planId": { "$exists": true } } }, { "$match": { "participants": { "$exists": true } } }, { "$match": { "participants": { "$exists": true } } }, { "$match": { "active": true } } ] //query 2 [ { "$lookup": { "from": "participant", "localField": "participantId", "foreignField": "_id", "as": "participants" } }, { "$unwind": { "path": "$participants", "preserveNullAndEmptyArrays": true } }, { "$lookup": { "from": "subscription", "localField": "participantId", "foreignField": "userId", "as": "subscriptions" } }, { "$unwind": { "path": "$subscriptions", "preserveNullAndEmptyArrays": true } }, { "$lookup": { "from": "subscriptionPlan", "localField": "subscriptions.planId", "foreignField": "_id", "as": "subscriptionPlans" } }, { "$unwind": { "path": "$subscriptionPlans", "preserveNullAndEmptyArrays": true } }, { "$match": { "nutritionistID": { "$oid": "64782249defe1c75d7689cbd" } } }, { "$match": { "subscriptions.planId": { "$exists": false } } }, { "$match": { "participants": { "$exists": true } } }, { "$match": { "participants": { "$exists": true } } }, { "$match": { "active": true } } ] for tavishi table is -> userNutrionistMapping
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter