【发布时间】:2019-07-03 03:58:40
【问题描述】:
这个很好用:
{
name: {
first: { type: String, required: true },
last: { type: String, required: true }
}
}
但是这个不行
{
name: {
required: true,
first: { type: String },
last: { type: String }
}
}
它甚至不会开始:
/Users/albertgao/codes/temp/aaa/node_modules/mongoose/lib/schema.js:751 throw new TypeError(
Invalid schema configuration: \${name}` is not ` + ^TypeError:无效的架构配置:
True不是路径name.required上的有效类型。
如何说我希望name 是必需的而不设置其每个子字段?
谢谢
【问题讨论】:
标签: mongoose