-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
None
-
Affects Version/s: 4.4.3
-
Component/s: None
-
Labels:None
-
ALL
-
Consider the follow sequence of three commands:
db.myCollection.remove({}) db.myCollection.update({_id:"rxTY3n1RHf4qV6xA3E5ydXY="}, { "$min":{ "scheduledAt":new Date("2020-12-01T10:00:00Z") } },{upsert:true}) db.myCollection.find({})
When the last `find()` is executed immedeality, I get:
{ "_id" : "rxTY3n1RHf4qV6xA3E5ydXY=", "scheduledAt" : ISODate("2020-12-01T10:00:00Z") }
However, after waiting a second or more, I get for find():
{ "_id" : "rxTY3n1RHf4qV6xA3E5ydXY=", "scheduledAt" : ISODate("2021-02-13T11:19:24.001Z") }
Note that the `scheduledAt` field has been flipped to the current timestamp.
The idea of the update query above is to only update `scheduledAt` when the given value is less than the current value. Initially (during the insert), the given value should be taken.
This seems to work fine with other data types (such as integer), but not for the date data type.
See also https://imgur.com/a/iGzKrDn