I have following Json structure-
[{
cName:"A",
"datastores" : [
{
"status":"unused"
},
{
"name" : "datastore1",
"status":"used"
},
{
"name" : "onNetApp7m",
"status":"used"
},
{
"name" : "datastore1",
"status":"used"
}
],
},
{
cName:"B",
"datastores" : [
{
"name" : "dsn",
"status":"used"
},
{
"name" : "dsn",
"status":"used"
},
{
"name" : "datastore2",
"status":"used"
}
],
}
]
I want to find only such names from array/list "ds" whose count is greater than 1. I want following output-
[{
"cName":"A",
"name" : "datastore1",
"count": 2
},
{
"cName":"B",
"name" : "dsn",
"count": 2
}]
Currently, for getting count, I am handling it in my code logic. Is it possible to get count from query itself using mongo??
dshas been changed todatastores- was it a typo?