Different timestamp behaviour for different operators on nested subdocuments #12119
Closed
2 tasks done
Labels
confirmed-bug
We've confirmed this is a bug in Mongoose and will fix it.
Milestone
Prerequisites
Mongoose version
6.3.3
Node.js version
12
MongoDB server version
4.5
Description
When updating a nested document array, the timestamps of the nested documents are only updated in certain cases.
When using
findOneAndUpdate
and updating the nested document via$set
operator, the timestamps are not updated in certain cases even if thetimestamps
option is enabled on the child schema.Automatic update of the timestamps on the deepest schema only works if either all nodes in-between have option
timestamp: true
OR when using the$push
operator.This is due to function
applyTimestampsToSingleNested
(and respectivelyapplyTimestampsToDocumentArray
) exiting too early when the timestamp option on the current node is not set, ignoring all child nodes from there.Steps to Reproduce
Expected Behavior
Timestamps should also update on nested subdocuments.
The text was updated successfully, but these errors were encountered: