0

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")}}})
Paulo Victor
  • 906
  • 2
  • 10
  • 18

1 Answers1

0

Date created with JodaTime is not equal to the one created with ISODate : ISODate("2027-06-02T18:06:40Z")

Try to create iso DateTime as follow :

new DateTime("2013-01-19T15:28:58.851Z");

See github issue for more informations : https://github.com/bguerout/jongo/issues/187

Benoît Guérout
  • 1,977
  • 3
  • 21
  • 30