Example usage for com.mongodb.client.model FindOneAndDeleteOptions sort

List of usage examples for com.mongodb.client.model FindOneAndDeleteOptions sort

Introduction

In this page you can find the example usage for com.mongodb.client.model FindOneAndDeleteOptions sort.

Prototype

Bson sort

To view the source code for com.mongodb.client.model FindOneAndDeleteOptions sort.

Click Source Link

Usage

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

License:Open Source License

@Override
public io.vertx.ext.mongo.MongoClient findOneAndDeleteWithOptions(String collection, JsonObject query,
        FindOptions findOptions, Handler<AsyncResult<JsonObject>> resultHandler) {
    requireNonNull(collection, "collection cannot be null");
    requireNonNull(query, "query cannot be null");
    requireNonNull(findOptions, "find options cannot be null");
    requireNonNull(resultHandler, "resultHandler cannot be null");

    JsonObject encodedQuery = encodeKeyWhenUseObjectId(query);

    Bson bquery = wrap(encodedQuery);//  w  w w  .j a va  2 s.com
    FindOneAndDeleteOptions foadOptions = new FindOneAndDeleteOptions();
    foadOptions.sort(wrap(findOptions.getSort()));
    foadOptions.projection(wrap(findOptions.getFields()));

    MongoCollection<JsonObject> coll = getCollection(collection);
    coll.findOneAndDelete(bquery, foadOptions, wrapCallback(resultHandler));
    return this;
}