Class FindOptions

    • Constructor Summary

      Constructors 
      Constructor Description
      FindOptions()
      Creates an empty options instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      FindOptions batchSize​(int batchSize)
      Sets the number of documents to return per batch.
      FindOptions collation​(com.mongodb.client.model.Collation collation)
      Sets the collation
      FindOptions copy()
      Makes a copy of these find options
      FindOptions cursorType​(com.mongodb.CursorType cursorType)
      Sets the cursor type.
      int getBatchSize()
      Gets the number of documents to return per batch.
      com.mongodb.client.model.Collation getCollation()
      Returns the collation options
      com.mongodb.CursorType getCursorType()
      Get the cursor type.
      int getLimit()
      Gets the limit to apply.
      long getMaxAwaitTime​(java.util.concurrent.TimeUnit timeUnit)
      The maximum amount of time for the server to wait on new documents to satisfy a tailable cursor query.
      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.
      boolean isNoCursorTimeout()
      The server normally times out idle cursors after an inactivity period (10 minutes) to prevent excess memory use.
      boolean isOplogReplay()
      Users should not set this under normal circumstances.
      boolean isPartial()
      Get partial results from a sharded cluster if one or more shards are unreachable (instead of throwing an error).
      FindOptions limit​(int limit)
      Sets the limit to apply.
      FindOptions maxAwaitTime​(long maxAwaitTime, java.util.concurrent.TimeUnit timeUnit)
      Sets the maximum await execution time on the server for this operation.
      FindOptions maxTime​(long maxTime, java.util.concurrent.TimeUnit timeUnit)
      Sets the maximum execution time on the server for this operation.
      FindOptions modifier​(java.lang.String key, java.lang.Object value)
      Adds a modifier to the find operation
      FindOptions noCursorTimeout​(boolean noCursorTimeout)
      The server normally times out idle cursors after an inactivity period (10 minutes) to prevent excess memory use.
      FindOptions oplogReplay​(boolean oplogReplay)
      Users should not set this under normal circumstances.
      FindOptions partial​(boolean partial)
      Get partial results from a sharded cluster if one or more shards are unreachable (instead of throwing an error).
      FindOptions readConcern​(com.mongodb.ReadConcern readConcern)
      Sets the readConcern
      FindOptions readPreference​(com.mongodb.ReadPreference readPreference)
      Sets the readPreference
      FindOptions 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

      • FindOptions

        public FindOptions()
        Creates an empty options instance.
    • Method Detail

      • copy

        public FindOptions copy()
        Makes a copy of these find options
        Returns:
        the new copy
      • 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
        MongoDB documentation
        reference/method/cursor.maxTimeMS/#cursor.maxTimeMS Max Time
      • getMaxAwaitTime

        public long getMaxAwaitTime​(java.util.concurrent.TimeUnit timeUnit)
        The maximum amount of time for the server to wait on new documents to satisfy a tailable cursor query. This only applies to a TAILABLE_AWAIT cursor. When the cursor is not a TAILABLE_AWAIT cursor, this option is ignored. On servers >= 3.2, this option will be specified on the getMore command as "maxTimeMS". The default is no value: no "maxTimeMS" is sent to the server with the getMore command. On servers < 3.2, this option is ignored, and indicates that the driver should respect the server's default value A zero value will be ignored.
        Parameters:
        timeUnit - the time unit to return the result in
        Returns:
        the maximum await execution time in the given time unit
        MongoDB documentation
        reference/method/cursor.maxTimeMS/#cursor.maxTimeMS Max Time
      • maxAwaitTime

        public FindOptions maxAwaitTime​(long maxAwaitTime,
                                        java.util.concurrent.TimeUnit timeUnit)
        Sets the maximum await execution time on the server for this operation.
        Parameters:
        maxAwaitTime - the max await time. A zero value will be ignored, and indicates that the driver should respect the server's default value
        timeUnit - the time unit, which may not be null
        Returns:
        this
        MongoDB documentation
        reference/method/cursor.maxTimeMS/#cursor.maxTimeMS Max Time
      • modifier

        public FindOptions modifier​(java.lang.String key,
                                    java.lang.Object value)
        Adds a modifier to the find operation
        Parameters:
        key - the modifier name
        value - the modifier value
        Returns:
        this
      • isNoCursorTimeout

        public boolean isNoCursorTimeout()
        The server normally times out idle cursors after an inactivity period (10 minutes) to prevent excess memory use. If true, that timeout is disabled.
        Returns:
        true if cursor timeout is disabled
      • noCursorTimeout

        public FindOptions noCursorTimeout​(boolean noCursorTimeout)
        The server normally times out idle cursors after an inactivity period (10 minutes) to prevent excess memory use. Set this option to prevent that.
        Parameters:
        noCursorTimeout - true if cursor timeout is disabled
        Returns:
        this
      • isOplogReplay

        public boolean isOplogReplay()
        Users should not set this under normal circumstances.
        Returns:
        if oplog replay is enabled
      • oplogReplay

        public FindOptions oplogReplay​(boolean oplogReplay)
        Users should not set this under normal circumstances.
        Parameters:
        oplogReplay - if oplog replay is enabled
        Returns:
        this
      • isPartial

        public boolean isPartial()
        Get partial results from a sharded cluster if one or more shards are unreachable (instead of throwing an error).
        Returns:
        if partial results for sharded clusters is enabled
      • partial

        public FindOptions partial​(boolean partial)
        Get partial results from a sharded cluster if one or more shards are unreachable (instead of throwing an error).
        Parameters:
        partial - if partial results for sharded clusters is enabled
        Returns:
        this
      • getCursorType

        public com.mongodb.CursorType getCursorType()
        Get the cursor type.
        Returns:
        the cursor type
      • cursorType

        public FindOptions cursorType​(com.mongodb.CursorType cursorType)
        Sets the cursor type.
        Parameters:
        cursorType - the cursor type
        Returns:
        this
      • getReadPreference

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

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

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

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

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

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