I can except a field from query results declaring it like:
field: {type: 'string', select: false}
Is but it possible to do that with _id and __v field? I tried
_id: {select: false}
But It seems not to work
You can do this as long as you also include the type of the field in the schema definitions:
_id: {type: mongoose.Schema.ObjectId, select: false},
__v: {type: Number, select: false},
However, that's going to prevent Mongoose from being able to find your model instance (and update its __v) on a save unless you explicitly include those fields in your find. So make sure you know what you're doing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With