I need a MongoDB query to get the only value from the document. I have the following two documents. I want to get the only value of service
key from the second document.
{
"develop-48" : [
{
"analytics" : "f58b6fc81b",
"service" : "3e449ce020e2",
"cdm" : "03e9e4f9423fd"
}
]
}
and
{
"develop-12" : [
{
"analytics" : "f58b6fc54b",
"service" : "3e449ce020d3",
"cdm" : "03e9e4f9423fd"
}
]
}
The query that I have tried is
db.den.find({},{"develop-12.service":1, "_id": 0})
and the output that I am getting is { }
{ "develop-12" : [ { "service" : "3e449ce020d3" } ] }
The expected output is 3e449ce020d3
If it is not possible, suggest me the best possible way to achieve this