Class CountOperation

java.lang.Object
com.mongodb.operation.CountOperation
All Implemented Interfaces:
AsyncReadOperation<Long>, ReadOperation<Long>

@Deprecated public class CountOperation extends Object implements AsyncReadOperation<Long>, ReadOperation<Long>
Deprecated.
An operation that executes a count.
Since:
3.0
  • Constructor Details

    • CountOperation

      public CountOperation(MongoNamespace namespace)
      Deprecated.
      Construct a new instance.
      Parameters:
      namespace - the database and collection namespace for the operation.
    • CountOperation

      public CountOperation(MongoNamespace namespace, com.mongodb.internal.client.model.CountStrategy countStrategy)
      Deprecated.
      Construct a new instance.
      Parameters:
      namespace - the database and collection namespace for the operation.
      countStrategy - the strategy to use for calculating the count.
  • Method Details

    • getFilter

      public BsonDocument getFilter()
      Deprecated.
      Gets the query filter.
      Returns:
      the query filter
    • filter

      public CountOperation filter(BsonDocument filter)
      Deprecated.
      Sets the filter to apply to the query.
      Parameters:
      filter - the filter, which may be null.
      Returns:
      this
    • retryReads

      public CountOperation retryReads(boolean retryReads)
      Deprecated.
      Enables retryable reads if a read fails due to a network error.
      Parameters:
      retryReads - true if reads should be retried
      Returns:
      this
      Since:
      3.11
    • getRetryReads

      public boolean getRetryReads()
      Deprecated.
      Gets the value for retryable reads. The default is true.
      Returns:
      the retryable reads value
      Since:
      3.11
    • getHint

      public BsonValue getHint()
      Deprecated.
      Gets the hint to apply.
      Returns:
      the hint, which should describe an existing
    • hint

      public CountOperation hint(BsonValue hint)
      Deprecated.
      Sets the hint to apply.
      Parameters:
      hint - a value describing the index which should be used for this operation.
      Returns:
      this
    • getLimit

      public long getLimit()
      Deprecated.
      Gets the limit to apply. The default is 0, which means there is no limit.
      Returns:
      the limit
    • limit

      public CountOperation limit(long limit)
      Deprecated.
      Sets the limit to apply.
      Parameters:
      limit - the limit
      Returns:
      this
    • getSkip

      public long getSkip()
      Deprecated.
      Gets the number of documents to skip. The default is 0.
      Returns:
      the number of documents to skip, which may be null
    • skip

      public CountOperation skip(long skip)
      Deprecated.
      Sets the number of documents to skip.
      Parameters:
      skip - the number of documents to skip
      Returns:
      this
    • getMaxTime

      public long getMaxTime(TimeUnit timeUnit)
      Deprecated.
      Gets the maximum execution time on the server for this operation. The default is 0, which places no limit on the execution time.
      Parameters:
      timeUnit - the time unit to return the result in
      Returns:
      the maximum execution time in the given time unit
    • maxTime

      public CountOperation maxTime(long maxTime, TimeUnit timeUnit)
      Deprecated.
      Sets the maximum execution time on the server for this operation.
      Parameters:
      maxTime - the max time
      timeUnit - the time unit, which may not be null
      Returns:
      this
    • getCollation

      public Collation getCollation()
      Deprecated.
      Returns the collation options
      Returns:
      the collation options
      Since:
      3.4
    • collation

      public CountOperation collation(Collation collation)
      Deprecated.
      Sets the collation options

      A null value represents the server default.

      Parameters:
      collation - the collation options to use
      Returns:
      this
    • execute

      public Long execute(ReadBinding binding)
      Deprecated.
      Description copied from interface: ReadOperation
      General execute which can return anything of type T
      Specified by:
      execute in interface ReadOperation<Long>
      Parameters:
      binding - the binding to execute in the context of
      Returns:
      T, the result of the execution
    • executeAsync

      public void executeAsync(AsyncReadBinding binding, SingleResultCallback<Long> callback)
      Deprecated.
      Description copied from interface: AsyncReadOperation
      General execute which can return anything of type T
      Specified by:
      executeAsync in interface AsyncReadOperation<Long>
      Parameters:
      binding - the binding to execute in the context of
      callback - the callback to be called when the operation has been executed
    • asExplainableOperation

      public ReadOperation<BsonDocument> asExplainableOperation(ExplainVerbosity explainVerbosity)
      Deprecated.
      Gets an operation whose execution explains this operation.
      Parameters:
      explainVerbosity - the explain verbosity
      Returns:
      a read operation that when executed will explain this operation
    • asExplainableOperationAsync

      public AsyncReadOperation<BsonDocument> asExplainableOperationAsync(ExplainVerbosity explainVerbosity)
      Deprecated.
      Gets an operation whose execution explains this operation.
      Parameters:
      explainVerbosity - the explain verbosity
      Returns:
      a read operation that when executed will explain this operation