嗨,所以我有这个猫鼬模式
series: [
{
fileName: { type: String, required: true },
episode: { type: Number, required: true, unique: true, index: true, createIndexes: true }
}
]
我用它来添加到嵌套数组
"$push": {
"series": {
"$each": filesNames,
"$sort": { "episode": 1 }
}
}
我正试图通过确保其唯一性来验证剧集字段
我使用了 mongoose-unique-validator ,但是即使值是uniqe,它也会给我带来错误:
Validation failed: series: Validation failed: episode: this.ownerDocument(...).model is not a function
我还尝试了$ addToSet也不起作用
感谢您的帮助