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

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

Introduction

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

Prototype

FindIterable<TDocument> find(ClientSession clientSession, Bson filter);

Source Link

Document

Finds all documents in the collection.

Usage

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

License:Open Source License

private FindIterable<JsonObject> doFind(String collection, WriteOption writeOption, JsonObject query,
        FindOptions options) {/*  ww  w .j av a  2  s. co  m*/
    MongoCollection<JsonObject> coll = getCollection(collection, writeOption);
    Bson bquery = wrap(encodeKeyWhenUseObjectId(query));
    FindIterable<JsonObject> find = coll.find(bquery, JsonObject.class);
    if (options.getLimit() != -1) {
        find.limit(options.getLimit());
    }
    if (options.getSkip() > 0) {
        find.skip(options.getSkip());
    }
    if (options.getSort() != null) {
        find.sort(wrap(options.getSort()));
    }
    if (options.getFields() != null) {
        find.projection(wrap(options.getFields()));
    }
    return find;
}