炎炎设计
这是您的问题的答案。db.getCollection('users').aggregate([ {$match : {admin : 1}}, {$lookup: {from: "posts",localField: "_id",foreignField: "owner_id",as: "posts"}}, {$project : { posts : { $filter : {input : "$posts" , as : "post", cond : { $eq : ['$$post.via' , 'facebook'] } } }, admin : 1 }}])或者,您可以使用mongodb group选项。db.getCollection('users').aggregate([ {$match : {admin : 1}}, {$lookup: {from: "posts",localField: "_id",foreignField: "owner_id",as: "posts"}}, {$unwind : "$posts"}, {$match : {"posts.via":"facebook"}}, { $group : { _id : "$_id", posts : {$push : "$posts"} }}])