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

add $setOnUpdate to update operation

    XMLWordPrintableJSON

Details

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

    Description

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

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: