I'm having a MongoDB collection which looks same as below document and I wanted to find only one field values count which presents within the embedded array object.
I tried below query to fetch the data but doesn't work
db.mycollection.find({'quizzes':{skill:'html'}}).pretty()
below is the mongo document structure with sample value. the structure is the same as my original document
{
"user": "values",
"date": "234-234-234-234",
"quizzes":[
{
"skill": "html",
"score": "12"
}
]
}
From the above document, I wanted to fetch only the skill field values which present within quizzes array which is an embedded document. my output should be like
{
"html": 10,
"php": 20,
"C#": 15,
"java": 18,
.
.
.
.
.
}