我使用猫鼬作为ODM。
我有一个<$>
模型,其中包含对某些其他模态的一些引用,以及对Unit
的一系列引用,如下所示:
unitFeatures
现在,我想查询并获取与特定Unit: {
unitSize: {type: ObjectId,ref: "unitsize"},
unitFeatures: [{type: ObjectId,ref: "unitfeature"}],
name: String,
price: Number
}
ID和不同单位功能匹配的单位列表。
这是我尝试过的:
unitSize
但是我从中得到的是独特的let unitsList = await Unit.find({unitSize: ...id}).distinct("unitFeatures")
列表,而不是具有独特单位特征的单位列表。
如何查询以获取具有唯一unitFeatures
的单位列表?