To output ‘id’ instead of ‘_id’ with Node.js MongoDB, we call set to modify the toJSON method.
For instance, we write
Schema.set("toJSON", {
virtuals: true,
});
to call set with an object that sets virtuals to true to change _id to id and return it.