更新时间:2023-12-01 22:19:52
要在名为type
的嵌入式对象中定义字段,您需要使用对象符号来定义其类型,或者Mongoose认为其正在定义对象的类型.父对象.
To define a field in an embedded object named type
, you need to use the object notation to define its type or Mongoose thinks it's defining the type of the parent object.
因此将您的架构更改为:
So change your schema to:
var memberSchema = mongoose.Schema({
'project' : {
'type' : Schema.Types.ObjectId,
'ref' : 'Project'
},
'first' : String,
'last' : String,
'email' : String,
'tracker' : {
'etag' : String,
'id' : String,
'photoLink' : String,
'role' : String,
'type' : {'type': String}, // Here...
},
'survey' : {
'etag' : String,
'id' : String,
'photoLink' : String,
'role' : String,
'type' : {'type': String}, // ...and here
},
});