mongoose validator 表单验证器内怎么查询?
var schema = mongoose.Schema({
name: {
type: String,
required: '请输入客户名称',
}, // 姓名
mobile: {
type: String,
validate: {
validator: function(v) {
// 这里要对当前表 做一些查询。。。应该怎么写?
},
message: '验证失败信息'
}
}
});
var model = mongoose.model('customer', schema);