I have a collection where every document has this kind of structure:
{
docName: "Document Name",
probabilities: [
{ topicName:"topic1", prob: 0.3 },
{ topicName:"topic2", prob: 0.4 },
{ topicName:"topic3", prob: 0.23 }
...
]
otherField: data,
...
}
I need to trnaform them into something like this:
{
docName: "Document Name",
topic1: 0.3,
topic2: 0.4,
topic3: 0.23,
...
otherField: data,
...
}
I tried using $arrayToObject and $objectToArray but I didn't figure out how to make it work.
Thanks in advance for your help!