Class CountOptions


  • public class CountOptions
    extends java.lang.Object
    The options for a count operation.
    Since:
    1.3
    MongoDB documentation
    reference/command/count/ Count
    • Constructor Summary

      Constructors 
      Constructor Description
      CountOptions()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      CountOptions collation​(com.mongodb.client.model.Collation collation)
      Sets the collation
      com.mongodb.client.model.Collation getCollation()
      Returns the collation options
      java.lang.String getHint()
      Gets the hint to apply.
      int getLimit()
      Gets the limit to apply.
      long getMaxTime​(java.util.concurrent.TimeUnit timeUnit)
      Gets the maximum execution time on the server for this operation.
      com.mongodb.ReadConcern getReadConcern()
      Returns the readConcern
      com.mongodb.ReadPreference getReadPreference()
      Returns the readPreference
      int getSkip()
      Gets the number of documents to skip.
      CountOptions hint​(java.lang.String hint)
      Sets the hint to apply.
      CountOptions limit​(int limit)
      Sets the limit to apply.
      CountOptions maxTime​(long maxTime, java.util.concurrent.TimeUnit timeUnit)
      Sets the maximum execution time on the server for this operation.
      CountOptions readConcern​(com.mongodb.ReadConcern readConcern)
      Sets the readConcern
      CountOptions readPreference​(com.mongodb.ReadPreference readPreference)
      Sets the readPreference
      CountOptions skip​(int skip)
      Sets the number of documents to skip.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CountOptions

        public CountOptions()
    • Method Detail

      • collation

        public CountOptions collation​(com.mongodb.client.model.Collation collation)
        Sets the collation
        Parameters:
        collation - the collation
        Returns:
        this
        Since server release
        3.4
      • getCollation

        public com.mongodb.client.model.Collation getCollation()
        Returns the collation options
        Returns:
        the collation options
        Since server release
        3.4
      • getHint

        public java.lang.String getHint()
        Gets the hint to apply.
        Returns:
        the hint, which should describe an existing
      • getMaxTime

        public long getMaxTime​(java.util.concurrent.TimeUnit timeUnit)
        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
      • getReadConcern

        public com.mongodb.ReadConcern getReadConcern()
        Returns the readConcern
        Returns:
        the readConcern
        Since server release
        3.2
      • getReadPreference

        public com.mongodb.ReadPreference getReadPreference()
        Returns the readPreference
        Returns:
        the readPreference
      • hint

        public CountOptions hint​(java.lang.String hint)
        Sets the hint to apply.
        Parameters:
        hint - the name of the index which should be used for the operation
        Returns:
        this
      • maxTime

        public CountOptions maxTime​(long maxTime,
                                    java.util.concurrent.TimeUnit timeUnit)
        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
      • readConcern

        public CountOptions readConcern​(com.mongodb.ReadConcern readConcern)
        Sets the readConcern
        Parameters:
        readConcern - the readConcern
        Returns:
        this
        Since server release
        3.2
      • readPreference

        public CountOptions readPreference​(com.mongodb.ReadPreference readPreference)
        Sets the readPreference
        Parameters:
        readPreference - the readPreference
        Returns:
        this