-
Type: Task
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Query Language
-
None
-
Query Optimization
Currently in the update command, if you specify 'c' in the individual element of the 'updates' array, and the update description 'u' is not a pipeline-update, you'll get an error "code: 51198, errmsg: 'Constant values may only be specified for pipeline updates'".
db.people.insertOne({name: "Andy"}) db.runCommand( { update: "people", updates: [ { q: { $expr: { $eq: [ "$name", "$$nameVar" ] } }, u: { $inc: { score: 1 } }, multi: true, c: {nameVar: "Andy"} } ] } )
This prevents using parameters defined in 'c' in the 'q' filter part of the update.
Also, it is not consistent with 'let' where you can set parameters on the command level, and it will not produce an error for the non-pipeline updates.
db.runCommand( { update: "people", updates: [ { q: { $expr: { $eq: [ "$name", "$$nameVar" ] } }, u: { $inc: { score: 1 } }, multi: true } ], let: {nameVar: "Andy"} } )
- is depended on by
-
DRIVERS-2183 Support 'let' option in BulkWriteOptions
- Closed
- is related to
-
SERVER-63704 Allow for each individual delete to accept parameters
- Backlog