Java 类com.mongodb.client.model.CountOptions 实例源码

项目:edison-microservice    文件:AbstractMongoRepository.java   
/**
 * Updates the document if the document's ETAG is matching the given etag (conditional put).
 * <p>
 * Using this method requires that the document contains an "etag" field that is updated if
 * the document is changed.
 * </p>
 *
 * @param value    the new value
 * @param eTag     the etag used for conditional update
 * @param maxTime  max time for the update
 * @param timeUnit the time unit for the maxTime value
 * @return {@link UpdateIfMatchResult}
 */
public UpdateIfMatchResult updateIfMatch(final V value,
                                         final String eTag,
                                         final long maxTime,
                                         final TimeUnit timeUnit) {
    final K key = keyOf(value);
    if (key != null) {
        final Bson query = and(eq(AbstractMongoRepository.ID, key), eq(ETAG, eTag));

        final Document updatedETaggable = collectionWithWriteTimeout(maxTime, timeUnit).findOneAndReplace(query, encode(value), new FindOneAndReplaceOptions().returnDocument(AFTER));
        if (isNull(updatedETaggable)) {
            final boolean documentExists = collection()
                    .count(eq(AbstractMongoRepository.ID, key), new CountOptions().maxTime(maxTime, timeUnit)) != 0;
            if (documentExists) {
                return CONCURRENTLY_MODIFIED;
            }

            return NOT_FOUND;
        }

        return OK;
    } else {
        throw new IllegalArgumentException("Key must not be null");
    }
}
项目:dragoman    文件:MongoDatasetDao.java   
@Override
public boolean exists(String id) {
  Observable<Long> count =
      getCollection().count(Filters.eq("id", id), new CountOptions().limit(1));

  return count.toBlocking().single() > 0;
}
项目:dragoman    文件:MongoAuthenticationDao.java   
@Override
public boolean isValid(String userName, String password) {
  Observable<Long> count =
      getCollection()
          .count(filter(userName, passwordUtil.toHash(password)), new CountOptions().limit(1));
  return count.toBlocking().single() > 0;
}
项目:djigger    文件:ThreadInfoAccessorImpl.java   
public long count(Bson mongoQuery, Date from, Date to, long timeout, TimeUnit timeUnit) throws TimeoutException {
    mongoQuery = buildQuery(mongoQuery, from, to);

    CountOptions options = new CountOptions();
    options.maxTime(timeout, timeUnit);

    try {
        return threadInfoCollection.count(mongoQuery, options);
    } catch(MongoExecutionTimeoutException e) {
        throw new TimeoutException("Count exceeded time limit");
    }
}
项目:ibm-performance-monitor    文件:ProfiledMongoClientTest.java   
@Test
public void testCount()
{
    assertEquals(8, coll.count());
    assertEquals(4, coll.count(Filters.eq("name", "Alto")));
    assertEquals(4, coll.count(Filters.eq("name", "Alto"), new CountOptions()));
}
项目:AbacusUtil    文件:AsyncMongoDBExecutor.java   
public CompletableFuture<Long> count(final String collectionName, final Bson filter, final CountOptions options) {
    return asyncExecutor.execute(new Callable<Long>() {
        @Override
        public Long call() throws Exception {
            return dbExecutor.count(collectionName, filter, options);
        }
    });
}
项目:AbacusUtil    文件:MongoCollectionExecutor.java   
public long count(final Bson filter, final CountOptions options) {
    if (options == null) {
        return coll.count(filter);
    } else {
        return coll.count(filter, options);
    }
}
项目:AbacusUtil    文件:AsyncMongoCollectionExecutor.java   
public CompletableFuture<Long> count(final Bson filter, final CountOptions options) {
    return asyncExecutor.execute(new Callable<Long>() {
        @Override
        public Long call() throws Exception {
            return collExecutor.count(filter, options);
        }
    });
}
项目:mongo-java-driver-rx    文件:MongoCollectionImpl.java   
@Override
public Observable<Long> count(final Bson filter, final CountOptions options) {
    return RxObservables.create(Observables.observe(new Block<SingleResultCallback<Long>>() {
        @Override
        public void apply(final SingleResultCallback<Long> callback) {
            wrapped.count(filter, options, callback);
        }
    }), observableAdapter);
}
项目:mongo-java-driver-reactivestreams    文件:MongoCollectionImpl.java   
@Override
public Publisher<Long> count(final Bson filter, final CountOptions options) {
    return new ObservableToPublisher<Long>(observe(new Block<SingleResultCallback<Long>>() {
        @Override
        public void apply(final SingleResultCallback<Long> callback) {
            wrapped.count(filter, options, callback);
        }
    }));
}
项目:mongo-java-driver-reactivestreams    文件:MongoCollectionImpl.java   
@Override
public Publisher<Long> count(final ClientSession clientSession, final Bson filter, final CountOptions options) {
    return new ObservableToPublisher<Long>(observe(new Block<SingleResultCallback<Long>>() {
        @Override
        public void apply(final SingleResultCallback<Long> callback) {
            wrapped.count(clientSession, filter, options, callback);
        }
    }));
}
项目:dragoman    文件:MongoAuthenticationDao.java   
@Override
public boolean exists(String userName) {
  Observable<Long> count =
      getCollection().count(Filters.eq("name", userName), new CountOptions().limit(1));
  return count.toBlocking().single() > 0;
}
项目:AbacusUtil    文件:MongoDBExecutor.java   
public long count(final String collectionName, final Bson filter, final CountOptions options) {
    return collExecutor(collectionName).count(filter, options);
}
项目:AbacusUtil    文件:MongoCollectionExecutor.java   
public boolean exists(final Bson filter) {
    return coll.count(filter, new CountOptions().limit(1)) > 0;
}
项目:reactive-hamster    文件:QueryResultListModel.java   
@Override
public long getSize(int max) {
    CountOptions co = new CountOptions();
    co.limit(max);
    return table.getCollection().count(query.getQuery());
}
项目:mongo-java-driver-rx    文件:MongoCollectionImpl.java   
@Override
public Observable<Long> count() {
    return count(new BsonDocument(), new CountOptions());
}
项目:mongo-java-driver-rx    文件:MongoCollectionImpl.java   
@Override
public Observable<Long> count(final Bson filter) {
    return count(filter, new CountOptions());
}
项目:edison-microservice    文件:AbstractMongoRepository.java   
public long size(final long maxTime, final TimeUnit timeUnit) {
    return collection().count(new BsonDocument(), new CountOptions().maxTime(maxTime, timeUnit));
}
项目:mongo-java-driver-reactivestreams    文件:MongoCollectionImpl.java   
@Override
public Publisher<Long> count() {
    return count(new BsonDocument(), new CountOptions());
}
项目:mongo-java-driver-reactivestreams    文件:MongoCollectionImpl.java   
@Override
public Publisher<Long> count(final Bson filter) {
    return count(filter, new CountOptions());
}
项目:mongo-java-driver-reactivestreams    文件:MongoCollectionImpl.java   
@Override
public Publisher<Long> count(final ClientSession clientSession) {
    return count(clientSession, new BsonDocument(), new CountOptions());
}
项目:mongo-java-driver-reactivestreams    文件:MongoCollectionImpl.java   
@Override
public Publisher<Long> count(final ClientSession clientSession, final Bson filter) {
    return count(clientSession, filter, new CountOptions());
}
项目:mongo-java-driver-rx    文件:MongoCollection.java   
/**
 * Counts the number of documents in the collection according to the given options.
 *
 * @param filter  the query filter
 * @param options the options describing the count
 * @return an Observable with a single element indicating the number of documents
 */
Observable<Long> count(Bson filter, CountOptions options);
项目:mongo-java-driver-reactivestreams    文件:MongoCollection.java   
/**
 * Counts the number of documents in the collection according to the given options.
 *
 * @param filter  the query filter
 * @param options the options describing the count
 * @return a publisher with a single element indicating the number of documents
 */
Publisher<Long> count(Bson filter, CountOptions options);
项目:mongo-java-driver-reactivestreams    文件:MongoCollection.java   
/**
 * Counts the number of documents in the collection according to the given options.
 *
 * @param clientSession the client session with which to associate this operation
 * @param filter  the query filter
 * @param options the options describing the count
 * @return a publisher with a single element indicating the number of documents
 * @mongodb.server.release 3.6
 * @since 1.7
 */
Publisher<Long> count(ClientSession clientSession, Bson filter, CountOptions options);