mingo
    Preparing search index...

    Class Cursor<T>

    The Cursor class provides a mechanism for iterating over a collection of data with support for filtering, projection, sorting, skipping, and limiting results. It is designed to be chainable and supports lazy evaluation for efficient data processing.

    Type Parameters

    • T

      The type of the elements in the cursor.

    Index

    Constructors

    • Creates an instance of the Cursor class.

      Type Parameters

      • T

      Parameters

      • source: Source

        The source of data to be iterated over.

      • predicate: Predicate<unknown>

        A function or condition to filter the data.

      • projection: AnyObject

        An object specifying the fields to include or exclude in the result.

      • Optionaloptions: Options

        Optional settings to customize the behavior of the cursor.

      Returns Cursor<T>

    Methods

    • Returns an iterator for the cursor, allowing it to be used in for...of loops. The iterator fetches all the results from the cursor.

      Returns Iterator

      An iterator over the fetched results.

    • Return remaining objects in the cursor as an array. This method exhausts the cursor

      Returns T[]

    • Sets the collation options for the cursor. Collation allows users to specify language-specific rules for string comparison, such as case sensitivity and accent marks.

      Parameters

      Returns Cursor<T>

      The current cursor instance for chaining.

    • Returns the number of objects return in the cursor. This method exhausts the cursor

      Returns number

    • Applies the provided callback function to each element in the cursor.

      Parameters

      • f: ArrayCallback<void, T>

        A callback function that is invoked for each element in the cursor.

      Returns void

    • Determines if there are more elements available in the cursor.

      Returns boolean

      true if there are more elements to iterate over, otherwise false.

    • Limits the number of items returned by the cursor.

      Parameters

      • n: number

        The maximum number of items to return.

      Returns Cursor<T>

      The current cursor instance for chaining.

    • Transforms each element in the cursor using the provided callback function.

      Type Parameters

      • R

      Parameters

      • f: ArrayCallback<R, T>

        A callback function.

      Returns R[]

      An array of transformed elements.

    • Returns a cursor that begins returning results only after passing or skipping a number of documents.

      Parameters

      • n: number

        the number of results to skip.

      Returns Cursor<T>

      Returns the cursor, so you can chain this call.

    • Returns results ordered according to a sort specification.

      Parameters

      • modifier: AnyObject

        an object of key and values specifying the sort order. 1 for ascending and -1 for descending

      Returns Cursor<T>

      Returns the cursor, so you can chain this call.