Using a MongoDB aggregate query, how do I convert an array of documents to a single document. The array can have N number of documents.
Before
{
"_id": "10217941",
"data": [
{
"count": 2,
"score": "0.5"
},
{
"count": 6,
"score": "0.3"
},
{
"count": 5,
"score": "0.8"
}
]
}
After
"_id": "10217941",
"0.3": 6,
"0.5": 2,
"0.8": 5