Details
-
New Feature
-
Status: Closed
-
Major - P3
-
Resolution: Won't Do
-
None
-
None
-
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
- is related to
-
SERVER-10711 $setOnInsert mods should not conflict with non-insert modifiers
-
- Closed
-
-
SERVER-14094 Conditional Updates: Conditionally update secondary fields if primary fields updated
-
- Closed
-
-
SERVER-2643 Allow Field Name Duplication with Modifiers
-
- Closed
-
-
SERVER-30587 Doing Upsert in Subdocuments when performing 'bulk' operations
-
- Closed
-
-
SERVER-51208 New field `$setOnUpdate` will solve some problems
-
- Closed
-
- related to
-
SERVER-6566 Support conditional updates: $updates
-
- Closed
-