本文整理汇总了Java中com.mongodb.client.model.CountOptions类的典型用法代码示例。如果您正苦于以下问题:Java CountOptions类的具体用法?Java CountOptions怎么用?Java CountOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CountOptions类属于com.mongodb.client.model包,在下文中一共展示了CountOptions类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: updateIfMatch
import com.mongodb.client.model.CountOptions; //导入依赖的package包/类
/**
* 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");
}
}
开发者ID:otto-de,项目名称:edison-microservice,代码行数:38,代码来源:AbstractMongoRepository.java
示例2: exists
import com.mongodb.client.model.CountOptions; //导入依赖的package包/类
@Override
public boolean exists(String id) {
Observable<Long> count =
getCollection().count(Filters.eq("id", id), new CountOptions().limit(1));
return count.toBlocking().single() > 0;
}
开发者ID:glytching,项目名称:dragoman,代码行数:8,代码来源:MongoDatasetDao.java
示例3: isValid
import com.mongodb.client.model.CountOptions; //导入依赖的package包/类
@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;
}
开发者ID:glytching,项目名称:dragoman,代码行数:8,代码来源:MongoAuthenticationDao.java
示例4: count
import com.mongodb.client.model.CountOptions; //导入依赖的package包/类
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");
}
}
开发者ID:denkbar,项目名称:djigger,代码行数:13,代码来源:ThreadInfoAccessorImpl.java
示例5: testCount
import com.mongodb.client.model.CountOptions; //导入依赖的package包/类
@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()));
}
开发者ID:dd00f,项目名称:ibm-performance-monitor,代码行数:8,代码来源:ProfiledMongoClientTest.java
示例6: count
import com.mongodb.client.model.CountOptions; //导入依赖的package包/类
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);
}
});
}
开发者ID:landawn,项目名称:AbacusUtil,代码行数:9,代码来源:AsyncMongoDBExecutor.java
示例7: count
import com.mongodb.client.model.CountOptions; //导入依赖的package包/类
public long count(final Bson filter, final CountOptions options) {
if (options == null) {
return coll.count(filter);
} else {
return coll.count(filter, options);
}
}
开发者ID:landawn,项目名称:AbacusUtil,代码行数:8,代码来源:MongoCollectionExecutor.java
示例8: count
import com.mongodb.client.model.CountOptions; //导入依赖的package包/类
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);
}
});
}
开发者ID:landawn,项目名称:AbacusUtil,代码行数:9,代码来源:AsyncMongoCollectionExecutor.java
示例9: count
import com.mongodb.client.model.CountOptions; //导入依赖的package包/类
@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);
}
开发者ID:mongodb,项目名称:mongo-java-driver-rx,代码行数:10,代码来源:MongoCollectionImpl.java
示例10: count
import com.mongodb.client.model.CountOptions; //导入依赖的package包/类
@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);
}
}));
}
开发者ID:mongodb,项目名称:mongo-java-driver-reactivestreams,代码行数:10,代码来源:MongoCollectionImpl.java
示例11: exists
import com.mongodb.client.model.CountOptions; //导入依赖的package包/类
@Override
public boolean exists(String userName) {
Observable<Long> count =
getCollection().count(Filters.eq("name", userName), new CountOptions().limit(1));
return count.toBlocking().single() > 0;
}
开发者ID:glytching,项目名称:dragoman,代码行数:7,代码来源:MongoAuthenticationDao.java
示例12: count
import com.mongodb.client.model.CountOptions; //导入依赖的package包/类
public long count(final String collectionName, final Bson filter, final CountOptions options) {
return collExecutor(collectionName).count(filter, options);
}
开发者ID:landawn,项目名称:AbacusUtil,代码行数:4,代码来源:MongoDBExecutor.java
示例13: exists
import com.mongodb.client.model.CountOptions; //导入依赖的package包/类
public boolean exists(final Bson filter) {
return coll.count(filter, new CountOptions().limit(1)) > 0;
}
开发者ID:landawn,项目名称:AbacusUtil,代码行数:4,代码来源:MongoCollectionExecutor.java
示例14: getSize
import com.mongodb.client.model.CountOptions; //导入依赖的package包/类
@Override
public long getSize(int max) {
CountOptions co = new CountOptions();
co.limit(max);
return table.getCollection().count(query.getQuery());
}
开发者ID:KAOREND,项目名称:reactive-hamster,代码行数:7,代码来源:QueryResultListModel.java
示例15: size
import com.mongodb.client.model.CountOptions; //导入依赖的package包/类
public long size(final long maxTime, final TimeUnit timeUnit) {
return collection().count(new BsonDocument(), new CountOptions().maxTime(maxTime, timeUnit));
}
开发者ID:otto-de,项目名称:edison-microservice,代码行数:4,代码来源:AbstractMongoRepository.java
示例16: count
import com.mongodb.client.model.CountOptions; //导入依赖的package包/类
/**
* 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);
开发者ID:mongodb,项目名称:mongo-java-driver-rx,代码行数:9,代码来源:MongoCollection.java
示例17: count
import com.mongodb.client.model.CountOptions; //导入依赖的package包/类
/**
* 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);
开发者ID:mongodb,项目名称:mongo-java-driver-reactivestreams,代码行数:9,代码来源:MongoCollection.java
注:本文中的com.mongodb.client.model.CountOptions类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论