-
Type: New Feature
-
Resolution: Duplicate
-
Priority: Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
The $currentDate operator can only be set by an update action. This is inconvenient when documents need to be created with a $currentDate field.
In my scenario I have an events collection in the database. This collection is populated with events which come from multiple different machines. Each event must be processed in the correct order which is based on the creation date (down to the millisecond). Hence I could not use the local machine time (because the machine clocks could be out of sync) or the ObjectId (whose creation date is limited to seconds). But I can use the servers $currentDate.
I do so at the moment by
- Adding an event
- Updating the event with the $currentData
- Filtering events where the $currentData field does not exist
This works. But the last two steps add additional complexity that "seems" like it could be avoided. i.e. If mongodb supported the insertion of $currentDate.
- duplicates
-
SERVER-13695 Support $currentDate expression for insert
- Backlog