Querying dates with Mongo Spring data vs Mongo's console (dates)
-
02-07-2021 - |
Pregunta
When querying for a date with Spring Data on MongoDB, the serialized DBObject could look something like {"start" : { "$lt" : {"$date" : "2012-08-06T16:19:14.044Z"}}}, which is valid in the context of Spring Data, but that query brings no results in Mongo's console. In the console this one does return the expected results {"start" : { "$lt" : ISODate("2012-08-06T16:19:14.044Z")}}}.
So what is making queries in Spring Data and Mongo's console different? Thx
Solución
You can't run the "serialized" query from Spring Data in the shell. The "serialized" query shows up in standard JSON, rather than the extended JSON that contains ISODate(), etc., and it's not compatible with the shell.
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow