In MongoDB, I can use $or[{key1:'value11', key2:'value12'}, {key1:'value21', key2:'value22'}, {key1:'value31', key2:'value32'}, ...]
to query several documents which matches at least one of the expressions in the $or
operator. Then how the thing can be done using Spring Data Reactive MonogoDB?
In particular, I define a entity class as:
@Document
public class MyDocument
{
@Id
private String id;
private String field1;
private String field2;
}
And then, the repository interface for the entity:
public interface MyDocumentRepository extends ReactiveMongoRepository<MyDocument, String>
The question now is how to define a method in MyDocumentRepository
to query the documents with field1
and field2
:
- There seems no proper keywords to create a query method (
findAllBy(field1AndField2)In
???) - If using JSON-based Query Methods, I really do know how to complete the Cloze test...
@Query("{$or:[(:fields)]} Flux<MyDocument> findAllBy????(Flux<???> fields)