-
Type: Improvement
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
This improvement can be impact to the server performance.
However, in some situation it can be save our life.
For example:
The company offices are stored in a collection.
'offices.active' field specifies that the office works currently or not. And 'active' status can be changed when needed.
Also new offices can be added into the collection.
A fictive document:
{ _id: "12", offices: [ { office_id: "1", active: true }, { office_id: "2", active: false }, ] }
What if I need to change the 'active' value of a document and I have to insert a new document if the searched document doesn't exist in the array and I have to do this via a bulk operation?
var col = db.collection('companies'); var batch = col.initializeUnorderedBulkOp(); var conditions = { _id: "12", "offices.office_id": "3" } var update = { $set: { active: true } } batch.find(conditions).upsert().updateOne(update);
As everybody can guess it doesn't work.
However it would be great if it works.
- duplicates
-
SERVER-6566 Support conditional updates: $updates
- Closed
- related to
-
SERVER-10711 $setOnInsert mods should not conflict with non-insert modifiers
- Closed
-
SERVER-13578 add $setOnUpdate to update operation
- Closed
-
SERVER-6566 Support conditional updates: $updates
- Closed