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
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.
© 2022 - 2024 — McMap. All rights reserved.