Database
db={"collection":[{"_id":{"$oid":"65aae0716f4773513a000001"},"actions":[{"$oid":"65aae071d1b967d5747bc6e6"},{"$oid":"65aae071d1b967d5747bc6e7"}],"username":"9X5OGbaa","key":1},{"_id":{"$oid":"65aae0716f4773513a000002"},"actions":[{"$oid":"65aae071d1b967d5747bc6e8"},{"$oid":"65aae071d1b967d5747bc6e9"},{"$oid":"65aae071d1b967d5747bc6ea"}],"username":"1uX8","key":3},{"_id":{"$oid":"65aae0716f4773513a000003"},"actions":[{"$oid":"65aae071d1b967d5747bc6eb"},{"$oid":"65aae071d1b967d5747bc6ec"},{"$oid":"65aae071d1b967d5747bc6ed"},{"$oid":"65aae071d1b967d5747bc6ee"}],"username":"Geuz8caa","key":1},{"_id":{"$oid":"65aae0716f4773513a000004"},"actions":[{"$oid":"65aae071d1b967d5747bc6ef"}],"username":"zhEFraaa","key":0},{"_id":{"$oid":"65aae0716f4773513a000005"},"actions":[{"$oid":"65aae071d1b967d5747bc6f0"},{"$oid":"65aae071d1b967d5747bc6f1"},{"$oid":"65aae071d1b967d5747bc6f2"},{"$oid":"65aae071d1b967d5747bc6f3"}],"username":"JMzy2ba","key":3}],"actions":[{"_id":{"$oid":"65aae071d1b967d5747bc6e6"},"key2":"CDPYqcaa","key1":"n3IIRda","status":2},{"_id":{"$oid":"65aae071d1b967d5747bc6e7"},"key2":"1uX8","key1":"hfbEIdaa","status":7},{"_id":{"$oid":"65aae071d1b967d5747bc6e8"},"key2":"DUDA","key1":"eLetGaaa","status":6},{"_id":{"$oid":"65aae071d1b967d5747bc6e9"},"key2":"JcEi1","key1":"JMzy2ba","status":5},{"_id":{"$oid":"65aae071d1b967d5747bc6ea"},"key2":"-MOlMa","key1":"Tr4ala","status":5},{"_id":{"$oid":"65aae071d1b967d5747bc6eb"},"key2":"Q68Hjba","key1":"rEoThcaa","status":6},{"_id":{"$oid":"65aae071d1b967d5747bc6ec"},"key2":"Fs4p","key1":"-bsx5baa","status":5},{"_id":{"$oid":"65aae071d1b967d5747bc6ed"},"key2":"0ueILbaa","key1":"qD4GIb","status":3},{"_id":{"$oid":"65aae071d1b967d5747bc6ee"},"key2":"LB-S","key1":"yw1X","status":3},{"_id":{"$oid":"65aae071d1b967d5747bc6ef"},"key2":"KrK3Mda","key1":"vXdvNd","status":4},{"_id":{"$oid":"65aae071d1b967d5747bc6f0"},"key2":"oiBupca","key1":"jaO1f","status":5},{"_id":{"$oid":"65aae071d1b967d5747bc6f1"},"key2":"1dXZSaa","key1":"KLXC","status":5},{"_id":{"$oid":"65aae071d1b967d5747bc6f2"},"key2":"BXVUXbaa","key1":"7Zuzma","status":4},{"_id":{"$oid":"65aae071d1b967d5747bc6f3"},"key2":"PnTMyda","key1":"JlhCTaa","status":6},{"_id":{"$oid":"65aae071d1b967d5747bc6f4"},"key2":"BmS9Haaa","key1":"EPyfXd","status":3},{"_id":{"$oid":"65aae071d1b967d5747bc6f5"},"key2":"RjKCUa","key1":"XanIGaa","status":2},{"_id":{"$oid":"65aae071d1b967d5747bc6f6"},"key2":"96HQ","key1":"fpWa","status":1},{"_id":{"$oid":"65aae071d1b967d5747bc6f7"},"key2":"kVeO2aa","key1":"xRG6Id","status":7},{"_id":{"$oid":"65aae071d1b967d5747bc6f8"},"key2":"4btqs","key1":"Qp3Tdba","status":6},{"_id":{"$oid":"65aae071d1b967d5747bc6f9"},"key2":"e3GCtb","key1":"ks1Wza","status":2},{"_id":{"$oid":"65aae071d1b967d5747bc6fa"},"key2":"eUBeEdaa","key1":"6Uuck","status":1},{"_id":{"$oid":"65aae071d1b967d5747bc6fb"},"key2":"-9-Ambaa","key1":"ZO9wYb","status":4},{"_id":{"$oid":"65aae071d1b967d5747bc6fc"},"key2":"GlV1","key1":"g4xM7b","status":7},{"_id":{"$oid":"65aae071d1b967d5747bc6fd"},"key2":"Kvbo-","key1":"B_o1Cd","status":7},{"_id":{"$oid":"65aae071d1b967d5747bc6fe"},"key2":"2FXW2da","key1":"5YA5-d","status":5},{"_id":{"$oid":"65aae071d1b967d5747bc6ff"},"key2":"6IChRbaa","key1":"lwIPncaa","status":5},{"_id":{"$oid":"65aae071d1b967d5747bc700"},"key2":"Kit6Gb","key1":"RIOv","status":5},{"_id":{"$oid":"65aae071d1b967d5747bc701"},"key2":"JLpAWdaa","key1":"Xjhqq","status":3},{"_id":{"$oid":"65aae071d1b967d5747bc702"},"key2":"hJhdgca","key1":"xaGMm","status":5},{"_id":{"$oid":"65aae071d1b967d5747bc703"},"key2":"ifl9Hd","key1":"05C-i","status":1}]}
Query
db.collection.aggregate([{$lookup:{from:"actions",localField:"actions",foreignField:"_id",pipeline:[{$project:{_id:0,status:1}}],as:"results"}},{$match:{"results.status":{$in:[4,5]}}}])