猫鼬抑制警告选项



我在控制台中收到以下警告,相应地,这是由于具有作为24个字符的十六进制字符串的顶级属性。

warn: mongoose: To create a new ObjectId please try `Mongoose.Types.ObjectId` instead of using `Mongoose.Schema.ObjectId`. Set the `suppressWarning` option if you're trying to create a hex char path in your schema.

在哪里可以设置suppressWarning选项?

在您的模式中尝试以下操作:

const itemIdSchema = new Schema({
key: String
},{suppressWarning: true});

相关内容

最新更新