Is there any way to write some query to mongo with @Query annotation and add paginaiton right into it. I have a method in repository
@Query("{'customer._id' : ?0 }")
List<Order> findOrderByCustomerName(String customerName);
and i want it to looks smth like this
@Query("{'customer._id' : ?0 }.skip{(?1 - 1) * ?2}.limit(?2)")
List<Order> findOrderByCustomerName(String customerName, int page, int size);
Is there any way to to it?
CodePudding user response:
You can add Pageable
as a parameter.
@Query("{'customer._id' : ?0 }")
List<Order> findOrderByCustomerName(String customerName, Pageable pageable);