Appendix D. Spring Data MongoDB keyword usage

Table D.1 describes the keywords that Spring Data MongoDB supports and how each method name generates query conditions.

Table D.1 Keyword usage in Spring Data MongoDB and resulting conditions

Keyword

Example

Condition

Is, Equals

findByUsername(String name)

findByUsernameIs(String name)

findByUsernameEquals(String name)

{"username":"name"}

And

findByUsernameAndEmail(String username, String email)

{"username":"username", "email":"email"}

Or

findByUsernameOrEmail (String username, String email)

{ "$or" : [{ "username" : "username"}, { "email" : "email"}]}

LessThan

findByRegistrationDateLessThan(LocalDate date)

{ "registrationDate" : { "$lt" : { "$date" : "date"}}} ...

Get Java Persistence with Spring Data and Hibernate now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.