Mongo Playground

Configuration

[{/**"_id": "621eedae92979fd8f0e9451d",*/"name":"Pallab Koley","shifts":[{"_id":"62636b9fcbda6d2b17f5cae0","month":"2022-05","shift":[{"date":"2022-05-01","shiftId":"622bb0f4b88dc92e3c2cac56"}]},{"_id":"62636bb3cbda6d2b17f5cae2","month":"2022-04","shift":[{"date":"2022-04-01","shiftId":"622bb0f4b88dc92e3c2cac56"}]}]},{"_id":"62626a7446ba9a911a623b37","name":"Pinki Das","shifts":[{"_id":"62636ba4cbda6d2b17f5cae1","month":"2022-05","shift":[{"date":"2022-05-01","shiftId":"622bb0f4b88dc92e3c2cac56"}]}]}]

Query

db.collection.aggregate([/** $match ,* $lookup,* Remove $unwind*/{$project:{id:1,name:1,shifts:{"$filter":{"input":"$shifts","cond":{$eq:["$$this.month","2022-04"]}}}}}])

Result