Is it possible to use $unwind
on the properties of an object when making a query with agregation
in MongoDB v3?
I need to extract the controls that meet certain conditions in each object of the array of objects in each area code. The question is that the keys in areas may vary. You can have two keys as in the example, but in other cases you can have up to 3 and 4 four keys.
{
id: 12,
name: "adsdf",
areas: {
clave1: [
{
"controles": ["valor1","valor2","valor3"]
},
{
"controles": ["valor4","valor5","valor6"]
}
],
clave2: [
{
"controles": ["valor7","valor8","valor9"]
},
{
"controles": ["valor10","valor11","valor12"]
}
]
}
}
A result would be something like this, for example:
{
id: 12,
name: "adsdf",
areas: {
clave1: [
{
"controles": ["valor1","valor3"]
},
{
"controles": ["valor5"]
}
],
clave2: [
{
"controles": ["valor9"]
},
{
"controles": ["valor12"]
}
]
}
}