【发布时间】:2021-03-31 03:41:08
【问题描述】:
我有 3 个相互引用的集合
A -> B -> C
我想在与 B 匹配并从 B 到 C 后过滤数据
集合 1
Products: [{
_id:ObjectId(),
name:"product1",
productCatalogue:[reference to productCatalogue collection]
},....]
系列 2
productCatalogue: [{
_id:ObjectId(),
name:"catelgoue1",
category:{
cat:[reference to category table],
sub1:[reference to category table],
sub2:[reference to category table]
}
},...]
系列 3
category: [{
_id:ObjectId(),
name:"cat1",
type:"parent"
},....]
我想过滤数据,以便使用聚合过滤具有 catalog:catelgoue1 和 category: cat1 的 products。
【问题讨论】:
-
@turivishal 确实如此,但你能解释一下
name: { $first: "$name" }, address: { $push: "$address" }$first 在这里的作用是什么,$name 代表什么是批准的答案
标签: mongodb mongoose aggregation