【发布时间】:2016-11-08 05:02:08
【问题描述】:
我的导航架构中有以下对象:
const navItem = new Schema ({
"title": { type: string, unique: true, required: "A Title is req."},
.............
"badge": {
"label": "string",
"class": "string"
}
..............
})
虽然徽章不是必需的,但如果徽章确实存在,则标签和类别是必需的。
如何在我的 mongoose 架构中正确显示可选徽章的这一要求?
谢谢
【问题讨论】: