Preview:
[
    {
        "$match": {
            "authorization": {
                "$ne": null
            }
        }
    },
    {
        "$match": {
            "email": {
                "$not": {
                    "$regularExpression": {
                        "pattern": "deleted",
                        "options": ""
                    }
                }
            }
        }
    },
 
    {
        "$lookup": {
            "from": "participant",
            "localField": "email",
            "foreignField": "email",
            "as": "userParticipant"
        }
    },
    {
        "$match": {}
    },
    {
        "$lookup": {
            "from": "masterSlot",
            "localField": "userParticipant._id",
            "foreignField": "navigatorId",
            "as": "slots"
        }
    },
    {
        "$lookup": {
            "from": "userCoachMapping",
            "localField": "userParticipant._id",
            "foreignField": "coachID",
            "as": "userCoachMapping"
        }
    },
    {
        "$project": {
        
            "isCoachActive": {
                "$arrayElemAt": [
                    "$userParticipant.active",
                    0
                ]
            },
        
            "email": {
                "$arrayElemAt": [
                    "$userParticipant.email",
                    0
                ]
            },
            "firstName": {
                "$arrayElemAt": [
                    "$userParticipant.firstName",
                    0
                ]
            },
            "coachProfileDescription": {
                "$arrayElemAt": [
                    "$userParticipant.coachProfileDescription",
                    0
                ]
            },
    
            "middleName": {
                "$arrayElemAt": [
                    "$userParticipant.middleName",
                    0
                ]
            },
            "lastName": {
                "$arrayElemAt": [
                    "$userParticipant.lastName",
                    0
                ]
            },
            "partnerShortCode": {
                "$arrayElemAt": [
                    "$userParticipant.partnerShortCode",
                    0
                ]
            },
    
            "role": {
                "$arrayElemAt": [
                    "$userParticipant.role",
                    0
                ]
            },
            "templateName": "$authorization.name",
            "servicePartnerShortCode": "$servicePartnerShortCode",
            "userVisibility": "$userVisibility",
    
            "Total Users": {
                "$size": {
                    "$filter": {
                        "input": "$userCoachMapping",
                        "as": "coach",
                        "cond": { "$eq": ["$$coach.userStatus", "ACTIVE"] }
                    }
                }
            }
            _id:0
        }
    },
    {
        $match:{
            "Total Users": { "$gt": 0 }
        }
    }
]
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