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

Provide $replace modifier

    XMLWordPrintable

    Details

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

      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

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

              Dates

              Created:
              Updated:
              Resolved: