Şu satırı dahil ederiz
cosntructor metoduimport com.mongodb.reactivestreams.client.MongoCollection;
Şöyle yaparız
MongoDatabase mongoDatabase = ...;MongoCollection<Document> helloCollection = mongoDatabase.getCollection("hello");
findOneAndUpdate metodu
Şöyle yaparız
Mono<Long> incrementAndGetHelloCount(String name) {FindOneAndUpdateOptions options = new FindOneAndUpdateOptions().upsert(true).returnDocument(ReturnDocument.AFTER);return Mono.from(helloCollection.findOneAndUpdate(Filters.eq(name),
Updates.inc("count", 1L), options)).map(counter -> counter.get("count", Long.class));}
Hiç yorum yok:
Yorum Gönder