-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Labels
type: enhancementA general enhancementA general enhancement
Description
I would like to concat an array with another field. If I use normal update then I can use $push operator but in pipeline update I have to use $concatArrays. The problem is that I have to create array from a field reference but it is not possible because input string is replaced by just a field reference.
For example I have document:
{
"myArray": ["something"],
"myField": "else"
}and as result I want to have:
{
"myArray": ["something", "else"]
}I want to run this MongoDB Update pipeline:
db.getCollection("myCollection").update({}, [
{ "$set": { myArray: {"$concatArrays": ["$myArray", [ "$myField" ] ]} }
])I tried to rewrite it to:
.set("myArray").toValue(ArrayOperators.ConcatArrays.arrayOf("myArray").concat("[\"$myField\"]"))but it is translated to:
{ "$set" : { "myArray" : { "$concatArrays" : ["$myArray", "$myField\"]"]}}}I would use custom AggregationExpresion but it has to return Document but this is unfortunately array.
Metadata
Metadata
Assignees
Labels
type: enhancementA general enhancementA general enhancement