id
property of object is not written to the database when using model.replaceOne
#13867
Closed
2 tasks done
Labels
acknowledged
Mongoose devs are aware of the issue and are working on a solution
Milestone
Prerequisites
Mongoose version
7.5.2
Node.js version
v18.17.1
MongoDB server version
7.0.0
Typescript version (if applicable)
No response
Description
I believe this issue has been caused by this: #13762
In my program, I have a structure that has an
id
property. This id is my own ID that I assign it using a separate system than mongodb's _id. These properties are separate. They have always worked just fine as separate properties, until version 7.5.2.Upon updating to version 7.5.2, I began to notice that, for some reason,
id
s were being set to undefined.I did some investigating, and it turns out that it was the replaceOne function, which for some reason, since version 7.5.2, now completely ignores the
id
parameter.Steps to Reproduce
Create a model with at least the below properties:
Then,
Expected Behavior
Simply, the ID property gets treated as a property of the document when being used in replaceOne, and not discarded. The second to last step in the Steps to Reproduce would log the document as it is after having been modified by replaceOne (in this case, not modified at all, but copied).
The text was updated successfully, but these errors were encountered: