-
Type: Bug
-
Resolution: Won't Do
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Aggregation Framework
-
Query
-
ALL
-
> db.test.insert({_id: 0, a: [1, 3, 5]}) > db.test.aggregate({$project: {"a.0": {$literal: 10}}}) { "_id" : 0, "a" : [ { "0" : 10 }, { "0" : 10 }, { "0" : 10 } ] }
This behavior replaces every element of the array, when what $set does is more elegant:
> db.test.update({a: [1, 3, 5]}, {$set: {"a.0": 10}}) > db.test.find() { "_id" : 0, "a" : [ 10, 3, 5 ] }
However, $set errors when "a" is not an array.
This behavior occurs in both the $project stage and the new $addFields stage.
- is related to
-
SERVER-5781 Implement $addFields aggregation stage for using expression language to add new fields to a document
- Closed
- related to
-
SERVER-30812 When using an array element as the local field for $lookup, $project doesn't work
- Closed