mongodb aggregation lookup match code example
Example: MongoDB Aggregation Lookup Match Array
db.users.aggregate([
{"$match":{"_id":ObjectId(..)}},
{"$lookup":{
"from":"groups",
"let":{"_id":"$_id"},
"pipeline":[
{"$match":{"$expr":{"$in":["$$_id","$members"]}}},
{"$unwind":"$members"},
{"$match":{"$expr":{"$eq":["$$_id","$members"]}}}
],
"as":"members"
}}
])