Last active
December 20, 2016 13:27
-
-
Save pulse00/72fbef0cef3caa364e6f0d3d308f83e0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// drop spring-data-rest and spring-rest-hateoas into your pom.xml | |
public interface BookRepository extends MongoRepository<Book, String> { | |
@Query(" {'name' : { $regex : '.*?0.*', $options: 'i' }} ") | |
Page<Book> filterBooksByName(@Param("term") String term, Pageable pageable); | |
} | |
// curl http://127.0.0.1:8080/book/search/filterBooksByName?term=Potter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"_embedded": { | |
"books": [ | |
{ "name" : "Harry Potter and the Philosopher's Stone" }, | |
{ "name" : "Harry Potter and the Goblet of Fire" }, | |
]}, | |
"_links": { | |
"next": { "href": "http://127.0.0.1:8080/book/search/filterBooksByName?term=Potter&page=1" } | |
}, | |
"page": { | |
"totalPages": 50, | |
"totalElements": 100, | |
"pageSize": 2, | |
"page": 0 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment