X
X
xoraxax2021-04-15 17:32:51
MongoDB
xoraxax, 2021-04-15 17:32:51

Spring data requests from date to mongodb don't work. How to fix?

Open the walker, write:
db.getCollection("MyCollection").find()
{ "_id" : ObjectId("607804af4b1d076c3b2939a0"), "requestTime" : ISODate("2021-04-15T09:17:35.593Z")}
shows that the record is there,

Spring data generates requests like this (this works in Atlas):
db.getCollection("MyCollection").find({ "requestTime" : { "$gt" : { "$date" : "2000-03- 30T12:41:33.112Z"}}}})
In local mongo, this query does not return any result, if you wrap the date in ISODate, nothing is returned either.

How to make everything work?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question