Example usage for com.mongodb.client MongoCollection getReadPreference

List of usage examples for com.mongodb.client MongoCollection getReadPreference

Introduction

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

Prototype

ReadPreference getReadPreference();

Source Link

Document

Get the read preference for the MongoCollection.

Usage

From source file:mongofx.js.api.FindResultIterable.java

License:Open Source License

@JsIgnore
@Override/* w w  w . ja  v a2  s . co  m*/
public MongoCursor<Document> iterator(int skip, int limit) {
    MongoCollection<Document> collection = getCollection();

    findOptions.skip(skip);
    findOptions.limit(limit);
    if (projection != null) {
        findOptions.projection(projection);
    }
    if (sort != null) {
        findOptions.sort(dbObjectFromMap(sort));
    }
    return new FindIterable(new MongoNamespace(mongoDatabase.getName(), collectionName),
            collection.getCodecRegistry(), //
            collection.getReadPreference(), getExecutor(), findQuery, findOptions).iterator();
}

From source file:mongofx.js.api.FindResultIterable.java

License:Open Source License

public ObjectListPresentation explain() {
    MongoCollection<Document> collection = getCollection();

    FindIterable findIterable = new FindIterable(new MongoNamespace(mongoDatabase.getName(), collectionName),
            collection.getCodecRegistry(), //
            collection.getReadPreference(), getExecutor(), findQuery, findOptions);

    BsonDocument res = findIterable.explainIterator(ExplainVerbosity.QUERY_PLANNER);
    return JsApiUtils.singletonIter(JsApiUtils.convertBsonToDocument(res));
}