-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Description
Do you want to request a feature or report a bug?
Report a bug.
What is the current behavior?
I am calling Model.findOneAndReplace() on a model with timestamps enabled. The resulting documents have no timestamps. Adding timestamps: true has no effect.
Calling Model.findOneAndUpdate() on the same model with overwrite: true results in correct timestamps, leading me to believe this issue is specific to Model.findOneAndReplace().
If the current behavior is a bug, please provide the steps to reproduce.
const product = await Product.findOneAndReplace(
{ externalId },
{ externalId, ...rest },
{ upsert: true, setDefaultsOnInsert: true, new: true }
).exec();I can't currently provide a standalone PR but I still wanted to get this report in, in case it's something obvious.
What is the expected behavior?
Insert or overwrite with timestamps, as this similar call does:
const product = await Product.findOneAndUpdate(
{ externalId },
{ externalId, ...rest },
{ overwrite: true, upsert: true, setDefaultsOnInsert: true, new: true }
);What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
Node.js 14.15.4, Mongoose 5.11.17, MongoDB 3.6.4 (MongoDB Atlas 4.4.3).