Example usage for com.mongodb.async.client MongoCollection updateMany

List of usage examples for com.mongodb.async.client MongoCollection updateMany

Introduction

In this page you can find the example usage for com.mongodb.async.client MongoCollection updateMany.

Prototype

void updateMany(ClientSession clientSession, Bson filter, List<? extends Bson> update,
        SingleResultCallback<UpdateResult> callback);

Source Link

Document

Update all documents in the collection according to the specified arguments.

Usage

From source file:io.vertx.ext.mongo.impl.MongoClientImpl.java

License:Open Source License

@Override
public io.vertx.ext.mongo.MongoClient updateCollectionWithOptions(String collection, JsonObject query,
        JsonObject update, UpdateOptions options, Handler<AsyncResult<MongoClientUpdateResult>> resultHandler) {
    requireNonNull(collection, "collection cannot be null");
    requireNonNull(query, "query cannot be null");
    requireNonNull(update, "update cannot be null");
    requireNonNull(options, "options cannot be null");
    requireNonNull(resultHandler, "resultHandler cannot be null");

    MongoCollection<JsonObject> coll = getCollection(collection, options.getWriteOption());
    Bson bquery = wrap(encodeKeyWhenUseObjectId(query));
    Bson bupdate = wrap(encodeKeyWhenUseObjectId(update));
    if (options.isMulti()) {
        coll.updateMany(bquery, bupdate, mongoUpdateOptions(options), toMongoClientUpdateResult(resultHandler));
    } else {/*from w  w  w.j  av  a2  s. com*/
        coll.updateOne(bquery, bupdate, mongoUpdateOptions(options), toMongoClientUpdateResult(resultHandler));
    }
    return this;
}