当我尝试更新不在架构中的字段时,邮递员收到 200 响应,但它没有显示任何错误

问题描述

enter image description here

这是我的邮递员,我在这里

解决方法

如果您使用的是 mongoose 并且希望在尝试保存架构中未指定的属性时抛出错误,则可以将 strict schema setting 设置为 'throw' .

const mySchema = new Schema(
  {
    myField1: String,myField2: Number,},{ strict: 'throw' },);