List of usage examples for com.mongodb.async.client MongoCollection findOneAndReplace
void findOneAndReplace(Bson filter, TDocument replacement, SingleResultCallback<TDocument> callback);
From source file:org.jnosql.diana.mongodb.document.MongoDBDocumentCollectionManagerAsync.java
License:Open Source License
private void update(DocumentEntity entity, SingleResultCallback<Document> callBack) { String collectionName = entity.getName(); com.mongodb.async.client.MongoCollection<Document> asyncCollection = asyncMongoDatabase .getCollection(collectionName); Document id = entity.find(ID_FIELD).map(d -> new Document(d.getName(), d.getValue().get())) .orElseThrow(() -> new UnsupportedOperationException( "To update this DocumentEntity " + "the field `id` is required")); asyncCollection.findOneAndReplace(id, getDocument(entity), callBack); }