0

how do i query mongodb to find out if a date in the database is within 1 week from today?

i tried stuff MongoRepository query for between dates but i kept getting an error

Class

    POJO class {
    
        private String id;
    
        private String userId;
    
        private String userName;
    
        private String email;
    
        private Date changeDate;
    }

Mongo Repo

  public interface POJOREPO extends MongoRepository<POJO, String> {

    POJOCLASS findByUserIdAndFindTopByOrderByChangeDateDesc(String userId, Date todayDate);

}

I would like it to return either a boolean or the entity meaning the date is within a week from the current date

endlessCode
  • 1,255
  • 4
  • 21
  • 36
  • What is the error that you are getting? – earandap Nov 09 '20 at 21:32
  • What do you mean by "within 1 week from today"? 7 days from today? Which day do you consider as the first day of the week? – Wernfried Domscheit Nov 09 '20 at 21:54
  • @earandap i just checked again org.springframework.beans.factory.UnsatisfiedDependencyException: No property findTopBy found for type. – endlessCode Nov 10 '20 at 04:40
  • @WernfriedDomscheit so if a user makes changes to their account today i want it to be they cant make any changes for a week or a specified period and for that i have to check the last date they made changes and see if its been less than a week from the current day they try to make another change – endlessCode Nov 10 '20 at 04:42

0 Answers0