You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched existing issues to ensure the bug has not already been reported
Mongoose version
8.0.3
Node.js version
20.10.0
MongoDB server version
4
Typescript version (if applicable)
No response
Description
I specify _id: false because I want to customize the primary key, but I still get an error when model.save(): MongooseError: document must have an _id before save, this is not a contradiction, when I specify _id: false, save should not have this error,otherwise, id: false loses its meaning.
Steps to Reproduce
_id: false
model.create or save
Expected Behavior
When id:false is specified, presave does not need to check the _id
The text was updated successfully, but these errors were encountered:
Unfortunately MongoDB doesn't allow you to save a document without an _id. MongoDB will create an _id property for you when you create a document, even if you don't specify one. We should update our docs to specify that the _id option is only useful for subdocuments.
Prerequisites
Mongoose version
8.0.3
Node.js version
20.10.0
MongoDB server version
4
Typescript version (if applicable)
No response
Description
I specify
_id: false
because I want to customize the primary key, but I still get an error when model.save():MongooseError: document must have an _id before save
, this is not a contradiction, when I specify_id: false
, save should not have this error,otherwise, id: false loses its meaning.Steps to Reproduce
Expected Behavior
When
id:false
is specified,presave
does not need to check the_id
The text was updated successfully, but these errors were encountered: