伙计,我在创建这样的模式时遇到了类似的问题:
QuestionnaireSchema = mongoose.Schema({
formId: Number,
name: String,
questions: [
{
type: String,
title: String,
alternatives:[{
label: String,
value: "Mixed"
}]
}
]
});
我的错误是我使用“type”作为字段名,这是猫鼬的保留字。
我只是改变:
type: String,
到
formType: String,
这很管用。
见:
https://github.com/Automattic/mongoose/issues/1760