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

add $setOnUpdate to update operation

    • 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 all operations specified in update are applied for update and upsert, and $setOnInsert only applies operations on insert/upsert.

      This request is to add a $setOnUpdate for operations that would be applied only on update (and not on upsert/insert) and possibly analogously $incOnUpdate. This would allow handling many of the use cases described in SERVER-2643 and SERVER-10711 (and possibly some others).

      Syntax might need to be different as "on update" all operations, not just $set might need to be accessible. Possible example:

      db.collection.update({_id:297},
            { $set:{updatedAt:"$currentTime"},
              $setOnInsert:{createdAt:"$currentTime",score:100},
              $setOnUpdate:{returnedAt:"$currentTime"},
              $incOnUpdate:{score:20}
           }, {upsert:true} );
      

            Assignee:
            backlog-server-query Backlog - Query Team (Inactive)
            Reporter:
            asya.kamsky@mongodb.com Asya Kamsky
            Votes:
            23 Vote for this issue
            Watchers:
            26 Start watching this issue

              Created:
              Updated:
              Resolved: