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

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

Introduction

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

Prototype

FindOneAndDeleteOptions

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);//from w w  w  .j a v  a2  s  .  c om
    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;
}

From source file:org.springframework.data.mongodb.core.ReactiveMongoTemplate.java

License:Apache License

private static FindOneAndDeleteOptions convertToFindOneAndDeleteOptions(Document fields, Document sort) {

    FindOneAndDeleteOptions result = new FindOneAndDeleteOptions();
    result = result.projection(fields).sort(sort);

    return result;
}