I have an object in the database that looks like:
{
'name': 'foo',
'table':
[
{
'date' : ISODate("2000-01-13T23:00:00Z")
},
{
'date' : ISODate("2000-01-14T23:00:00Z")
},
{
'date' : ISODate("2000-01-15T23:00:00Z")
},
{
'date' : ISODate("2000-01-16T23:00:00Z")
},
{
'date' : ISODate("2000-01-17T23:00:00Z")
}
]
}
I wish to query for the following result:
{
'name': 'foo',
'table':
[
{
'date' : ISODate("2000-01-15T23:00:00Z")
},
{
'date' : ISODate("2000-01-16T23:00:00Z")
}
]
}
So I'm looking for a way to extract the children that is between two different dates.
So far I have tried the following:
db.stock.find({'table.date' : {$gte : '2000-01-15', $lt : '2000-01-17'}});
db.stock.find({'table.date' : {$gte : new Date('2000-01-15'), $lt : new Date('2000-01-17')}});
db.stock.find({'table.date' : {$gte : '2000-01-15T23:00:00Z', $lt : '2000-01-17T23:00:00Z'}});
db.stock.find({'table.date' : {$gte : ISODate('2000-01-15T23:00:00Z'), $lt : ISODate('2000-01-17T23:00:00Z')}});
db.stock.find({'table.date' : {$gte : new Date('2000-01-15T23:00:00Z'), $lt : new Date('2000-01-17T23:00:00Z')}});
Is this possible to do? If so, how can it be resolved?