Querying mongodb with long values from spring boot

Viewed 30

Trying to fetch all the documents that are 20 days old from mongo db

@Query("{'$expr': {'$gte': [{'$subtract': [?1, '$createdAt']}, ?0]}}")
List<Model> findAllModelCreatedBefore(long timeDifference, long currentTime);

createdAt is a field in the model.

I'm calling the method by

modelRepository.findAllModelCreatedBefore(1728000000, System.currentTimeMillis());

But getting org.bson.json.JsonParseException: JSON reader was expecting a value but found '}'.

0 Answers
Related