【发布时间】:2018-10-13 14:44:42
【问题描述】:
在我的架构中,我需要一个属性,它是一个必须始终不为空且不为未定义的数组。
所以我定义了它是必需的,但验证没有像我预期的那样工作,因为如果我省略该属性,则不会抛出错误。
如果是简单属性(不是数组),这将按我的预期工作
const nodeSchema = new Schema({
address: { type: String, required: true },
outputs: { type: [String], required: true }
})
【问题讨论】:
标签: mongodb mongoose mongoose-schema