I'm having some trouble with the following query:
documents()
.find("{values: {$elemMatch: {name: #, value: #}}}", "Date", new DateTime()
.withDate(2027, 6, 2)
.withHourOfDay(18)
.withMinuteOfHour(06)
.withSecondOfMinute(40)
.toDate()).as(Document.class);
It throws no error but returns an empty list.
However, on the console it runs succesfully and presents me with a result.
I was digging through the source code and I found out that actually Date
isn't being parsed to ISODate("yyyy-MM-ddTxxxxx")
, and instead is being parsed to {$date: "yyyy-MM-ddTxxxxx"}
.
I don't know if this is an issue or I'm plainly missing something. If someone can point me to the right direction, please do.
PS: as a reference, here is the console query:
db.documents.find({values: {$elemMatch: {"name": "Date", "value" : ISODate("2027-06-02T18:06:40Z")}}})