我有两个集合,如下所示。
类别架构
var CategorySchema = Schema({
categoryName: { type: String, required: true, unique: true },
subCategory: [{
subCategoryName: { type: String, required: true, unique: true },
subDescription: { type: String, required: true, unique: false },
isEnable: { type: Boolean, required: false, unique: false, default : true },
subCategoryIcon: { type: String, required: false, unique: false , default: null}
}],
description: { type: String, required: false, unique: false },
isEnable: { type: Boolean, required: false, unique: false , default: true},
recordedTime: { type: Date, required: true, unique: false, default: Date.now }
});
次要收藏
var TestSchema = Schema({
category : {type: String, required: true, unique: false},
subCategory : {type: String, required: true, unique: false},
otherInfo : {
...
},
});
所以我想做的是使用 category 和 subCategory 加入这两个集合,并在第二个集合中使用 subCategoryIcon项目 otherInfo 。我尝试了多种方式使用查找。但这对我不起作用。正确的方法是什么?