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

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

Introduction

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

Prototype

Bson projection

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

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