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

Provide $replace modifier

    • Type: Icon: New Feature New Feature
    • Resolution: Won't Do
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Write Ops
    • Labels:
      None
    • Query

      Currently the only way to replace the whole document in `update` query is to specify it at the top level:

      db.collection.update({_id: ...}, {new: 'document'})
      

      But this makes it problematic because we have to sanitize the new document if it is coming from untrusted source to remove any update operators. It would be really great if MongoDB would provide something a `$replace` update operator, which would work exactly like the query above, but would not allow any update operators:

      db.collection.update({_id: ...}, {$replace: {new: 'document'}})
      

            Assignee:
            backlog-server-query Backlog - Query Team (Inactive)
            Reporter:
            mitar NOVALUE Mitar
            Votes:
            0 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated:
              Resolved: