I am trying to get all the users within the specified date range, My database structure looks like this:
{
_id : ObjectId("58b545d4b57eeb2cc456248a"),
"attendance" : [
{
"2017-03-16" : ["58c108b9ebd9ae24dca81634"],
"2017-03-17" : ["58c108b9ebd9ae24dca81634"],
"2017-03-18" : ["58c108b9ebd9ae24dca81634"],
"2017-03-19" : ["58c108b9ebd9ae24dca81634"],
"2017-03-20" : ["58c108b9ebd9ae24dca81634","58c108b9ebd9ae24dca81635"]
},
{
"2017-03-17" : ["58c108b9ebd9ae24dca81634"],
"2017-03-18" : ["58c108b9ebd9ae24dca81634"],
"2017-03-19" : ["58c108b9ebd9ae24dca81634"],
"2017-03-20" : ["58c108b9ebd9ae24dca81634","58c108b9ebd9ae24dca81635"]
}
]
.......
}
and to query it:
routes.find({_id: ObjectId("58b545d4b57eeb2cc456248a"), $or:[{'attendance[0]' : {$gte: '2017-03-17' }}, {'attendance[1]': {$gte: '2017-03-17'}}]})
but it is not fetching any results.