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

Allow $currentDate in queries

    • Type: Icon: Improvement Improvement
    • Resolution: Duplicate
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 3.4.0
    • Component/s: Querying
    • None
    • Query

      There seems to be no way to retrieve the system date of the mongodb server. This is a problem if the client time is not synched with the server (which it will usually not be). Currently the only option is to use a new Date() from either javascript on the client or the language of the driver, or possibly using a $where.

      This could easily be solved by allowing $currentDate to be used in queries rather than just in updates.

      The problem with not having this is, for example, on a findAndModify when a Date or Timestamp value is part of the query. It would be best to have the corresponding date field be from a uniform base, such as what $currentDate is, namely the system time of the server. Consider when querying against an expiration time, it is somewhat useless from multiple servers, with only gross time intervals making sense.

            Assignee:
            backlog-server-query Backlog - Query Team (Inactive)
            Reporter:
            cjRay Alan Hengle [X]
            Votes:
            0 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated:
              Resolved: