Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-17540

Insert support for $currentDate

    • Type: Icon: New Feature New Feature
    • Resolution: Duplicate
    • Priority: Icon: Minor - P4 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.

            Assignee:
            Unassigned Unassigned
            Reporter:
            Shane Gannon Shane Gannon
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: