With Spring Data repositories, we are able to create queries to suit any situation. Earlier in this chapter, we saw findByName, which merely queries based on the domain object's name attribute.
The following table shows a more comprehensive collection of finders we can write with Spring Data MongoDB. To illustrate the breadth of these keywords, it presumes a domain model bigger than the Image class we defined earlier:
Finder Method |
Description |
findByLastName(...) |
Query based on lastName |
findByFirstNameAndLastName(...) |
Query based on firstName and lastName |
findByFirstNameAndManagerLastName(...) |
Query based on firstName and by a related manager's lastName |
findTop10ByFirstName(...) or findFirst10ByFirstName(...) |
Query based on firstName, but only return the first ten entries |