I want query sublist in mongo collections using Spring Data MongoDB. My Code is like
public interface SomeRepo extends MongoRepository<SomeDoc, String> {
@Query("{'field0': ?0, 'field1': ?1}, {'limit':?2, 'skip':?3}")
List<SomeDoc> findAllByField0AndFiled1(
Long field0,
Long field1,
Long limit,
Long skip
);
}
but limit
& skip
are not in Query Object
Log is
Created query Document{{field0=123, field1=456}} for Document{{}} fields.
how to pass them into query object?
Thanks to @prasad_ for the answer. Using @Aggregation can solve my question.
@Aggregation("{'field0': ?0, 'field1': ?1}, {limit': ?2, 'skip': ?3}")
List<SomeDoc> findAllByField0AndFiled1(
Long field0,
Long field1,
Long limit,
Long skip
);