This is my data in the collection:
{ "installation" : 200278 ,
"date" : [
{ "date" : "2014-12-28" ,
"values" : [
{ "time" : "2014-12-28 00:15:26" , "value" : 26},
{ "time" : "2014-12-28 00:30:26" , "value" : 15} ,
{ "time" : "2014-12-28 00:45:26" , "value" : 7} ,
{ "time" : "2014-12-28 01:00:26" , "value" : 32}
]
},
{ "date" : "2014-12-29" ,
"values" : [
{ "time" : "2014-12-29 00:15:26" , "value" : 26},
{ "time" : "2014-12-29 00:30:26" , "value" : 15} ,
{ "time" : "2014-12-29 00:45:26" , "value" : 7} ,
{ "time" : "2014-12-29 01:00:26" , "value" : 32}
]
}
]
},
{ "installation" : 200312
...
And I try to query this:
db.measure.find({"installation" : 200278 , "date.date" : "2014-12-28"},
{"date.date" : 1 , "_id" : 0})
.sort({"date.date" : 1})
First of all I do not understand why "date.date" does not only return the element with "2014-12-28". In addition maybe I get sorting wrong but not matter my sign on the 1 it still returns the same order.
Result:
{ "date" : [ { "date" : "2014-12-28" }, { "date" : "2014-12-29" } ] }
Clarification
What I want my query to return is only the element:
{ "date" : "2014-12-28" }
The sorting problem is an extension of my hacking on the Mongo api. And a wondering of how this querying works.