Closed
Description
Ankur Pathak opened DATAMONGO-1979 and commented
We support sorting in Repository methods like this:
interface IScanRepository extends MongoRepository<Scan, String> {
Page<UserScan> findByOrderByCreatedDesc(Pageable pageable);
}
But we don't support sorting in repository methods annotated with @Query
:
interface IScanRepository extends MongoRepository<Scan, String> {
@Query("{}")
Page<UserScan> findByOrderByCreatedDesc(Pageable pageable);
}
as @Query
annotation don't have any parameter to specify sort. Ideally it should have option to specify sort and also an alias to value parameter to specify filter, something like below:
interface IScanRepository extends MongoRepository<Scan, String> {
@Query(value/filter = "{}", sort = "\{ created : -1 }")
Page<UserScan> findByOrderByCreatedDesc(Pageable pageable);
}
So this will make uniform support for sorting in both type of repository methods.
Referenced from: pull request #566