var userId = ObjectId("65782514edde816188e0767f"); var clothType = 1; db.vml_test_user.aggregate([ { // Tìm user với 2 tham số id và loại áo quần $match: { _id: userId, "cloths.type": clothType } }, { $project: { // project more fields here // ... cloths: { // Filter chỉ lấy áo quần type = clothType $filter: { input: "$cloths", as: "item", cond: { $eq: ["$$item.type", clothType] } } } } }, { $lookup: { from: "vml_test_cloth", localField: "cloths._id", foreignField: "_id", as: "cloths" } }, ])