-
Type: New Feature
-
Resolution: Duplicate
-
Priority: Minor - P4
-
None
-
Affects Version/s: 1.1.3
-
Component/s: Querying
-
None
It'd be nice if there was the ability to tell Mongo on an upsert, "set this field only if a new document is created".
Example:
db.users.update(
{ foo: 'bar'}, { $set:
{ baz: 'bap' }, $iset:
{ create_time: new Date() }}, true)
You could also imagine an equivalent to only set fields when updating but not inserting, although when updating there are more things you might want to do than just set ($inc, $push, etc), this may need more thought as to best approach. Perhaps $updateonly which can then contain any number of possible modifications, e.g. { $updateonly: { $inc:
{ modifications: 1 }, $set:
{ modify_time: new Date() }}
- depends on
-
SERVER-390 upsert with x.y query misinterpreted by server
- Closed
- duplicates
-
SERVER-340 $setOnInsert modifier for upsert
- Closed