我有带有字段验证选项 min 的猫鼬模式:
export const CartSchema = new Schema < ICartSchema > ({
amount: {
type: Number,
default: 1,
min: 1
}
}, {
versionKey: false
});
当我尝试更新我的文档并设置值 <1 时,我没有收到一些错误并且文档获取值 <1
switch (type) {
case "inc": {
update = {
$inc: {
amount: 1
}
}
break;
}
case "dec": {
update = {
$inc: {
amount: -1
}
}
break;
}
default:
throw Error("Bad request");
}
猫鼬版^6.0.7