I have a document with a structure like –
Doc {
"DocName": "DocName",
"Array": [{
"Name": "Name1",
"Value": "Value1"
},{
"Name": "Name2",
"Value": "Value2"
},{
"Name": "Name3",
"Value": "Value3"
}]
}
Is it possible to query Mongo so that it will return multiple documents in a format like the one below?
{
DocName: "DocName",
Name: "Name1",
Value: "Value1"
},
{
DocName: "DocName",
Name: "Name2",
Value: "Value2"
},
{
DocName: "DocName",
Name: "Name3",
Value: "Value3"
}
With mapReduce
Record object:
Map function:
Reduce function:
Bringing it together:
The query:
The result:
It’s not exactly what you want but it should get you started.