【发布时间】:2018-11-21 01:33:01
【问题描述】:
我正在尝试从另一个集合中填充。
它给我一个这样的错误:
TypeError: Undefined type
Cat0你尝试过嵌套模式吗? 您只能使用 refs 或数组进行嵌套。
我的代码:
const ProductsSchema = new mongoose.Schema({
name: {
type: String
},
price: {
type: Number
},
category: [{
type: mongoose.Schema.Types.ObjectId,
ref: 'categories'
}]
});
tnx!
【问题讨论】: