1. $lookup
db.Article.aggregate([
{
$lookup: {
from: "Category",
as: "Category",
localField: "CategoryId",
foreignField: "_id"
}
}
])
2. 嵌套语句
db.Article.find({
CategoryId: {
$in: db.Category.find().toArray().map(x => x._id)
}
})
网友评论