Replies: 1 comment 1 reply
-
The setter is called twice because Mongoose calls setters on filter properties and update properties. So the setter runs once for In general, I would recommend you use defaults if you're looking to set a default value, not setters. You should also take a look at Mongoose's timestamps docs so you don't have to implement timestamps yourself. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, I've this schema and route:
I noted that the set function (date) is call two onces (why) and the record is not updated when the filter contain 'updatedAt' field too.
I use this data for verify:
If I remove the setter function from schema, it work fine.
Beta Was this translation helpful? Give feedback.
All reactions