0

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?

1 Answer 1

2

You can add Pageable as a parameter.

@Query("{'customer._id' : ?0 }")
List<Order> findOrderByCustomerName(String customerName, Pageable pageable);
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you. It's working.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.