I have MongoDB documents with this structure:
{
_id: 1
dates: [
ISODate ("2015-08-21T22: 00: 00Z")
ISODate ("2015-09-27T22: 00: 00Z")
],
...
}
In my example, we see that the document 1 was accessed:
- 2015-08-21
- 2015-09-27
In my application, I can filter by time period (start date, end date).
If in my application I filter the period "2015-09-01 - 2015-09-01":
Logically the document 1 should not be found because it was not consulted during this period. But with my tests, the document 1 is found.
What conditions must I use to filter the data correctly?
I tried that but it's fallible:
<?php
$begin = new \DateTime('2015-09-01');
$end = new \DateTime('2015-09-01');
$expr1 = $qb->expr()->field('dates')->gte($begin);
$expr2 = $qb->expr()->field('dates')->lte($end);
$qb
->addAnd($expr1)
->addAnd($expr2)
;
Thanks for your help, Yohann