mongoose suppressWarning option

Viewed 123

I am getting the following warning in console and accordingly this is due to having a top level property as a 24 character hex string.

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.

Where can I set suppressWarning option though?

1 Answers

In your schema try this:

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