Shape of the document(s) in the collection
[
{
"predictions": [
"611b85b9b2b924245526c125"
],
"_id": "611e40b6dd381f18cf63d15f",
"__v": 0
},
{
"predictions": [
"611b85b9b2b924245526c125"
],
"_id": "611e40b6dd381f18cf63d160",
"__v": 0
}
]
My Aggregation pipeline
ActiveFixture.aggregate([
{$match:{fixture:{$in:fixtureIds}}},
{$project:{"predictions":1, _id:0}},
{$unwind:"$predictions"},
{$group:{_id:'blah', "Predictions":{"$push":"$predictions"}}}
]).exec()
Current output:
[
{
"_id": "blah",
"Predictions": [
"611b85b9b2b924245526c125",
"611b85b9b2b924245526c125",
"611b85b9b2b924245526c125",
"611b85b9b2b924245526c125"
]
}
]
Desired output would be all values from predictions arrays as an single array:
["611b85b9b2b924245526c125", "611b85b9b2b924245526c125", "611b85b9b2b924245526c125"]
Any ideas, pointers would be much appreciated. Obviously I am well aware it's trivial to transform current output to desired shape with JS but goal is to achieve final product with MongoDB Aggregation