这是我的名为 slate(在线调度程序)的待办事项列表的应用程序 https://murmuring-ravine-25508.herokuapp.com/。 我想在密码长度中添加验证。我通过写作修改了架构
const userschema = new mongoose.Schema ({
email:String,
password:{
type:String,
minlength:5,
maxlength:10
}
});
但它什么也没做。
我不知道为什么架构没有更新。
我发现 {runValidators: true}
这是解决方案。但不知道在哪里添加它和它的完整代码。
答案 0 :(得分:0)
你应该试试
const userschema = new mongoose.Schema ({
email:
{
type: String
},
password:{
type:String,
minlength:5,
maxlength:10,
required: true
}
});