$查找多个级别没有$展开?
{ "_id" : ObjectId("5acdb8f65ea63a27c1facf86"), "name" : "ASA College - Manhattan Campus", "addedBy" : ObjectId("5ac8ba3582c2345af70d4658"), "reviews" : [ ObjectId("5acdb8f65ea63a27c1facf8b"), ObjectId("5ad8288ccdd9241781dce698") ]}
{ "_id" : ObjectId("5acdb8f65ea63a27c1facf8b"), "createdAt" : ISODate("2018-04-07T12:31:49.503Z"), "venue" : ObjectId("5acdb8f65ea63a27c1facf86"), "author" : ObjectId("5ac8ba3582c2345af70d4658"), "content" : "nice place", "comments" : [ ObjectId("5ad87113882d445c5cbc92c8") ],}
{ "_id" : ObjectId("5ad87113882d445c5cbc92c8"), "author" : ObjectId("5ac8ba3582c2345af70d4658"), "comment" : "dcfdsfdcfdsfdcfdsfdcfdsfdcfdsfdcfdsfdcfdsfdcfdsf", "review" : ObjectId("5acdb8f65ea63a27c1facf8b"), "__v" : 0}
{ "_id" : ObjectId("5ac8ba3582c2345af70d4658"), "firstName" : "Bruce", "lastName" : "Wayne", "email" : "bruce@linkites.com", "followers" : [ObjectId("5ac8b91482c2345af70d4650")]}
const venues = await Venue.findOne({ _id: id.id }) .populate({ path: 'reviews', options: { sort: { createdAt: -1 } }, populate: [ { path: 'author' }, { path: 'comments', populate: [{ path: 'author' }] } ] })
$lookup
$lookup
isFollow
$project
populate
...
$project: { isFollow: { $in: [mongoose.Types.ObjectId(req.user.id), '$followers'] }}
相关分类