spring-data-mongodb-reactive

Spring webflux ReactiveMongoOperations find by elemMatch

天涯浪子 提交于 2020-12-13 04:41:08
问题 I have a collection like this: {"type": "bbb", "category": "aaa", "from": "eee", "INTERLOCUTOR": ["test1", "test2"]} and I want to find INTERLOCUTOR have test1 ; how to use by ReactiveMongoOperations ? 回答1: db.collection.find({"INTERLOCUTOR" : "test1"}) 回答2: Using ReactiveMongoOperations and processing the returned reactor.core.publisher.Flux to print the query returned documents: ReactiveMongoOperations ops = new ReactiveMongoTemplate(MongoClients.create(), "test"); Criteria c = Criteria