db.collection().person {
name: String,
emails: [{type: String, unique: true}]
}.plugin(uniqueValidator) //const uniqueValidator = require('mongoose-unique-validator');
personA = {
name: 'Foo',
emails: ['foo1@com', 'foo2@com']
}
personB = {
name: 'Bar',
emails: ['bar1@com', 'foo1@com']
}
问题:当我从Web表单添加新的personB时,当我提交与personA.emails [0]复制的电子邮件“ foo1 @ com”时,它没有响应错误(应该是错误)。
是错误还是其他?我该如何解决? 谢谢