Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-13059

Investigate changes in SERVER-42007: Deprecate $currentDate update modifier

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • Server_Docs_20231030
    • Affects Version/s: None
    • Component/s: manual
    • Labels:
      None

      Description

      Downstream Change Summary

      The $currentDate update operator is being deprecated for MongoDB 4.4. As an alternative users can rewrite their updates using updates with aggregation pipelines and can use the $$NOW and $$CLUSTER_TIME aggregation system variables to access the current wall-clock and cluster time.

      In the following example, a document is updated using pipeline updates and $$NOW:

      > db.test.insert({_id: 1, value: null, lastUpdated: null})
      WriteResult({ "nInserted" : 1 })
      > db.test.find()
      { "_id" : 1, "value" : null, "lastUpdated" : null }
      > db.test.update({_id: 1}, [{$set: {value: 1, lastUpdated: "$$NOW"}}])
      WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
      > db.test.find()
      { "_id" : 1, "value" : 1, "lastUpdated" : ISODate("2019-10-01T13:27:55.583Z") }
      

      Description of Linked Ticket

      This can be better expressed using $$NOW and $$CLUSTER_TIME within a pipeline-style update and having two ways to do the same thing is confusing.

      Scope of changes

      Impact to Other Docs

      MVP (Work and Date)

      Resources (Scope or Design Docs, Invision, etc.)

            Assignee:
            kay.kim@mongodb.com Kay Kim (Inactive)
            Reporter:
            backlog-server-pm Backlog - Core Eng Program Management Team
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:
              2 years, 1 week, 6 days ago