Options
All
  • Public
  • Public/Protected
  • All
Menu

Type Parameters

Hierarchy

Index

Methods

  • bufferedCount(): number
  • Returns current buffered documents length

    Returns number

  • readBufferedDocuments(number?: number): T[]
  • Returns current buffered documents

    Parameters

    • Optional number: number

    Returns T[]

  • deprecated

    Callbacks are deprecated and will be removed in the next major version. See mongodb-legacy for migration assistance

    Returns Promise<boolean>

  • deprecated

    Callbacks are deprecated and will be removed in the next major version. See mongodb-legacy for migration assistance

    Parameters

    Returns void

  • Get the next available document from the cursor, returns null if no more documents are available.

    deprecated

    Callbacks are deprecated and will be removed in the next major version. See mongodb-legacy for migration assistance

    Returns Promise<T>

  • deprecated

    Callbacks are deprecated and will be removed in the next major version. See mongodb-legacy for migration assistance

    Parameters

    Returns void

  • deprecated

    Callbacks are deprecated and will be removed in the next major version. See mongodb-legacy for migration assistance

    Parameters

    Returns void | Promise<T>

  • Try to get the next available document from the cursor or null if an empty batch is returned

    deprecated

    Callbacks are deprecated and will be removed in the next major version. See mongodb-legacy for migration assistance

    Returns Promise<T>

  • deprecated

    Callbacks are deprecated and will be removed in the next major version. See mongodb-legacy for migration assistance

    Parameters

    Returns void

  • forEach(iterator: ((doc: T) => boolean | void)): Promise<void>
  • forEach(iterator: ((doc: T) => boolean | void), callback: <internal>.Callback<void>): void
  • Iterates over all the documents for this cursor using the iterator, callback pattern.

    If the iterator returns false, iteration will stop.

    Parameters

    • iterator: ((doc: T) => boolean | void)

      The iteration callback.

        • (doc: T): boolean | void
        • Parameters

          • doc: T

          Returns boolean | void

    Returns Promise<void>

  • deprecated

    Callbacks are deprecated and will be removed in the next major version. See mongodb-legacy for migration assistance

    Parameters

    • iterator: ((doc: T) => boolean | void)
        • (doc: T): boolean | void
        • Parameters

          • doc: T

          Returns boolean | void

    • callback: <internal>.Callback<void>

    Returns void

  • deprecated

    options argument is deprecated. Callbacks are deprecated and will be removed in the next major version. See mongodb-legacy for migration assistance

    Returns Promise<void>

  • deprecated

    Callbacks are deprecated and will be removed in the next major version. See mongodb-legacy for migration assistance

    Parameters

    Returns void

  • deprecated

    options argument is deprecated

    Parameters

    Returns Promise<void>

  • deprecated

    options argument is deprecated. Callbacks are deprecated and will be removed in the next major version. See mongodb-legacy for migration assistance

    Parameters

    Returns void

  • Returns an array of documents. The caller is responsible for making sure that there is enough memory to store the results. Note that the array only contains partial results when this cursor had been previously accessed. In that case, cursor.rewind() can be used to reset the cursor.

    Returns Promise<T[]>

  • deprecated

    Callbacks are deprecated and will be removed in the next major version. See mongodb-legacy for migration assistance

    Parameters

    Returns void

  • addCursorFlag(flag: "tailable" | "oplogReplay" | "noCursorTimeout" | "awaitData" | "partial" | "exhaust", value: boolean): ListCollectionsCursor<T>
  • Add a cursor flag to the cursor

    Parameters

    • flag: "tailable" | "oplogReplay" | "noCursorTimeout" | "awaitData" | "partial" | "exhaust"

      The flag to set, must be one of following ['tailable', 'oplogReplay', 'noCursorTimeout', 'awaitData', 'partial' -.

    • value: boolean

      The flag boolean value.

    Returns ListCollectionsCursor<T>

  • Map all documents using the provided function If there is a transform set on the cursor, that will be called first and the result passed to this function's transform.

    remarks

    Note Cursors use null internally to indicate that there are no more documents in the cursor. Providing a mapping function that maps values to null will result in the cursor closing itself before it has finished iterating all documents. This will not result in a memory leak, just surprising behavior. For example:

    const cursor = collection.find({});
    cursor.map(() => null);

    const documents = await cursor.toArray();
    // documents is always [], regardless of how many documents are in the collection.

    Other falsey values are allowed:

    const cursor = collection.find({});
    cursor.map(() => '');

    const documents = await cursor.toArray();
    // documents is now an array of empty strings

    Note for Typescript Users: adding a transform changes the return type of the iteration of this cursor, it does not return a new instance of a cursor. This means when calling map, you should always assign the result to a new variable in order to get a correctly typed cursor variable. Take note of the following example:

    example
    const cursor: FindCursor<Document> = coll.find();
    const mappedCursor: FindCursor<number> = cursor.map(doc => Object.keys(doc).length);
    const keyCounts: number[] = await mappedCursor.toArray(); // cursor.toArray() still returns Document[]

    Type Parameters

    • T = any

    Parameters

    • transform: ((doc: T) => T)

      The mapping transformation method.

        • (doc: T): T
        • Parameters

          • doc: T

          Returns T

    Returns AbstractCursor<T, AbstractCursorEvents>

  • Set a maxTimeMS on the cursor query, allowing for hard timeout limits on queries (Only supported on MongoDB 2.6 or higher)

    Parameters

    • value: number

      Number of milliseconds to wait before aborting the query.

    Returns ListCollectionsCursor<T>

  • rewind(): void
  • Rewind this cursor to its uninitialized state. Any options that are present on the cursor will remain in effect. Iterating this cursor will cause new queries to be sent to the server, even if the resultant data has already been retrieved by this cursor.

    Returns void

  • Returns a new uninitialized copy of this cursor, with options matching those that have been set on the current instance

    Returns ListCollectionsCursor<T>

  • listenerCount<EventKey>(type: string | symbol | EventKey): number
  • Type Parameters

    • EventKey extends "close"

    Parameters

    • type: string | symbol | EventKey

    Returns number

  • eventNames(): string[]
  • getMaxListeners(): number

Properties

errorMonitor: typeof errorMonitor

This symbol shall be used to install a listener for only monitoring 'error' events. Listeners installed using this symbol are called before the regular 'error' listeners are called.

Installing a listener using this symbol does not change the behavior once an 'error' event is emitted, therefore the process will still crash if no regular 'error' listener is installed.

captureRejectionSymbol: typeof captureRejectionSymbol
captureRejections: boolean

Sets or gets the default captureRejection value for all emitters.

defaultMaxListeners: number
parent: Db

Events

CLOSE: "close"

Accessors

  • Returns Long

  • Returns MongoDBNamespace

  • Returns ReadPreference

  • Returns ReadConcern

  • get closed(): boolean
  • Returns boolean

  • get killed(): boolean
  • Returns boolean

  • get loadBalanced(): boolean
  • Returns boolean

Constructors

Generated using TypeDoc