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

add $setOnUpdate to update operation

    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 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

              • Votes:
                23 Vote for this issue
                Watchers:
                27 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: