I am very new to MongoDb and experimenting to see if I can use it to store time series data.
I have inserted the following data...
{
"_id" : ObjectId("5785f186ed936527c05efa10"),
"Timestamp" : ISODate("2006-07-13T07:42:00.000Z"),
"Label1" : "Lab1",
"Attr" : "atrr1",
"Readings" : [
{
"DateTime" : ISODate("2006-07-13T07:42:06.355Z"),
"Value" : "22"
},
{
"DateTime" : ISODate("2006-07-13T07:42:07.355Z"),
"Value" : "22"
},
{
"DateTime" : ISODate("2006-07-13T07:42:08.355Z"),
"Value" : "22"
},
....
So, each document as the array Readings that hold DateTimes in 1 second intervals.
So, if I want to query between 2 datetimes, I am trying the following in the Robomongo query window...
db.getCollection('Timedata').find(
{
'Readings.DateTime':
{ $gt: '2005-07-13 07:42:13.355Z', $lt: '2010-07-13 07:42:13.355Z'}
})
However this always returns Fetched 0 record(s) in 11ms
where as it should actually return them all.
My syntax must be incorrect, but I just cannot find what is wrong with it and how to search for datetimes in a nested array as I have here. Would anyone have any ideas?
Thanks in advance!