So, my document is like the below example.
{
image: {imageUrl: "http://imageurlsite.com/xyz"},
additionalImages: [
{imageUrl: "http://imageurlsite.com/pdq"},
{imageUrl: "http://imageurlsite.com/lol"},
{imageUrl: "http://imageurlsite.com/zomg"}
]
}
With the MongoDB Aggregation Pipeline, how can I create a new array field from image and additionalImages without including the imageUrl part? I want the new field like this:
[
"http://imageurlsite.com/xyz",
"http://imageurlsite.com/pdq",
"http://imageurlsite.com/lol",
"http://imageurlsite.com/zomg"
]
I tried using the following in the $group stage, which partly works, but I just want the string values.
{
image: {$addToSet: "$image"},
additionalImages: {$addToSet: "$additionalImages"}
}
Unfortunately, the result of the above gives me this;
[
{imageUrl: "http://imageurlsite.com/xyz"},
{imageUrl: "http://imageurlsite.com/pdq"},
{imageUrl: "http://imageurlsite.com/lol"},
{imageUrl: "http://imageurlsite.com/zomg"}
]