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

Add $setOnInsert command

    XMLWordPrintableJSON

Details

    • Icon: New Feature New Feature
    • Resolution: Duplicate
    • Icon: Minor - P4 Minor - P4
    • None
    • None
    • None
    • None

    Description

      The upsert feature in Mongo is incredibly useful, but it often results in a lot of redundant $set operations when used in conjunction with counters/increment.

      This would be incredibly handy:

      toSetOnInsert = { }
      toSetOnInsert['name'] = 'test'

      toInc = { }
      toInc['foo'] = 1

      vals= { }
      vals['$setOnInsert'] = toSetOnInsert
      vals['$inc'] = toInc

      db.foo.update({_id: "foo"}, vals, true, false);

      Attachments

        Activity

          People

            Unassigned Unassigned
            rn@deftlabs.com Ryan Nitz
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: