Example usage for com.mongodb.client MongoCollection count

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

Introduction

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

Prototype

@Deprecated
long count(ClientSession clientSession);

Source Link

Document

Counts the number of documents in the collection.

Usage

From source file:uk.ac.ebi.eva.dbmigration.mongodb.ExtractAnnotationFromVariant.java

License:Apache License

@ChangeSet(order = "004", id = "updateAnnotationMetadata", author = "EVA")
public void updateAnnotationMetadata(MongoDatabase mongoDatabase) {
    final MongoCollection<Document> annotationMetadataCollection = mongoDatabase
            .getCollection(databaseParameters.getDbCollectionsAnnotationMetadataName());
    logger.info("4) update annotation metadata in collection {}", annotationMetadataCollection.getNamespace());

    String id = databaseParameters.getVepVersion() + "_" + databaseParameters.getVepCacheVersion();
    Document metadata = new Document(ID_FIELD, id);
    if (annotationMetadataCollection.count(metadata) == 0) {
        metadata.append(VEP_VERSION_FIELD, databaseParameters.getVepVersion()).append(CACHE_VERSION_FIELD,
                databaseParameters.getVepCacheVersion());

        annotationMetadataCollection.insertOne(metadata);
    }//from   w  w  w .  j  a v a 2  s. c  o  m
}