I have a collection in mongodb with nested data like this:
{
"lat" : "-33.890542",
"lng" : "151.274856",
"city" : "San Jose",
"area" : "SJSU",
"sensordata" : [
{
"timestmp" : NumberLong(1414850400000),
"temp" : NumberInt(21)
},
{
"timestmp" : NumberLong(1414850460000),
"temp" : NumberInt(12)
},
{
"timestmp" : NumberLong(1414850520000),
"temp" : NumberInt(13)
},
{
"timestmp" : NumberLong(1414850580000),
"temp" : NumberInt(15)
}
]
}
{
"lat" : "-33.890542",
"lng" : "151.274856",
"city" : "San Jose",
"area" : "SJSU1",
"sensordata" : [
{
"timestmp" : NumberLong(1414850400000),
"temp" : NumberInt(21)
},
{
"timestmp" : NumberLong(1414850460000),
"temp" : NumberInt(12)
},
{
"timestmp" : NumberLong(1414850520000),
"temp" : NumberInt(13)
},
{
"timestmp" : NumberLong(1414850580000),
"temp" : NumberInt(15)
}
]
}
What i want to do is fetch records based on certain condition of timestmp. eg: timestamp>1414850460000
So the entire record will be fetched but all the records under the Sensor data field will not be fetched. I am unable to formulate a query for this. Thanks