October 2018
Intermediate to advanced
556 pages
15h 18m
English
Even though the ReactiveMongoTemplate is used as a building block of a reactive repository, the class itself is very versatile. Sometimes it allows working with the database more efficiently than the higher-level repository does.
For example, let's implement a simple service that uses ReactiveMongoTemplate to find books by title using a regular expression. The implementation may look as follows:
public class RxMongoTemplateQueryService { private final ReactiveMongoOperations mongoOperations; // (1) // Constructor... public Flux<Book> findBooksByTitle(String titleRegExp) { // (2) Query query = Query.query(new Criteria("title") // (3) .regex(titleRegExp))) .limit(100); return mongoOperations .find(query, Book.class ...