organs: [
{
type: mongoose.Schema.Types.ObjectId,
ref: 'Organ',
healthValue: { // i want to add this field but it is becoming invalid, not generating auto with default val
type: Number,
default: 0,
}
},
],我有一个用户模式,并且在这个模式中还有器官键。我用推荐的方法保存器官属于用户器官。我也应该保持器官健康的价值,但我不能把它放在像上面这样的参考领域。我该怎么做?我不能添加更多键:值来填充(type & ref)字段吗?
发布于 2020-08-03 23:34:17
organs: [
{
organId: {
type: mongoose.Schema.Types.ObjectId,
ref: 'Organ',
},
healthValue: {
type: Number,
default: 0,
},
isOwned: {
type: Boolean,
default: false,
},
},
],我想我解决了上面的代码块,我确实使用了错误的语法。
https://stackoverflow.com/questions/63238150
复制相似问题