I need to achieve this simple thing. I have these 2 documents
1: {a="010", b="020", c="030"}
2: {a="030", b="040", c="050"}
I need to obtain the following document using mongodb aggregations:
{ result = [{a="010", b="020", c="030"}, {a="030", b="040", c="050"}] }
Thank you very much
CodePudding user response:
db.collection.aggregate([
{
$group:{
"_id": null,
"result": {
$push: "$$ROOT"
}
}
}
])
Group all the docs under result as an array.