I currently have a field in MongoDB that is a list of arrays. I would like to convert all this into a string, but I first need (I guess?) to concatenate my list of arrays into one single array before converting it.
Here is what my field looks like :
"SitesList" : [
[
"553550",
"496573",
"496574"
],
[
"553550",
"496573",
"496574"
],
[
"527772",
"565085"
],
[
"565085",
"563248"
],
[
"496576"
]
]
Here's what I tried so far to concatenate it (with concatArrays), but it's not working:
{ $addFields: {"Sites": { $concatArrays: ["$tdb.Data.site.list"]}}},
And what I would like to do ultimately to convert the final array into a string:
SitesList: {
$reduce: {
input: "$Sites",
initialValue: "",
in: {$concat: ["$$value",",", {$toString:"$$this"}]}
}
},
Can someone one help me please? :) Thanks in advance!
SitesListand format as desired on the client side?