【发布时间】:2019-08-16 18:29:31
【问题描述】:
我在 mongoose 上的架构遇到了一些错误。
我的架构如下:
{
accomodations : {
rooms : {
type : [{
rooms : [{
type : {
id : { type : Number },
name : {
ita : { type : String },
eng : { type : String },
},
numberOfRooms : { type : Number },
},
}],
boards : [{
id : { type : String },
type : {
id : { type : Number },
name : {
ita : { type : String },
eng : { type : String },
},
},
amount : {
currency : { type : String },
directPayment : { type : Boolean },
totalPrice : { type : Number },
mandatory : { type : Boolean },
priceAgency : { type : Number },
refundable : { type : Boolean },
markupPrice : { type : Number },
},
}],
amenities : [{ type : mongoose.Schema.Types.Mixed }],
}],
},
}
}
如果我使用“类型”作为属性名称,我会收到一个错误:
架构配置无效:[object Object] 不是数组 rooms 中的有效类型。有关有效架构类型的列表,请参见 http://bit.ly/mongoose-schematypes。
我需要在我的架构中有一个名为 type 的属性。
【问题讨论】: