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

Provide $replace modifier

    XMLWordPrintableJSON

Details

    • Icon: New Feature New Feature
    • Resolution: Won't Do
    • Icon: Major - P3 Major - P3
    • None
    • None
    • Write Ops
    • None
    • Query

    Description

      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'}})
      

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: