Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ChangeStream<TSchema, TChange>

Creates a new Change Stream instance. Normally created using {@link Collection#watch|Collection.watch()}.

Type Parameters

Hierarchy

Index

Constructors

  • new ChangeStream<TSchema, TChange>(): ChangeStream<TSchema, TChange>

Methods

  • Check if there is any document still available in the Change Stream

    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 Change Stream.

    deprecated

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

    Returns Promise<TChange>

  • deprecated

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

    Parameters

    Returns void

  • Try to get the next available document from the Change Stream's 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<<internal>.Document>

  • deprecated

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

    Parameters

    Returns void

  • Returns AsyncGenerator<TChange, void, void>

  • Close the Change Stream

    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

  • Return a modified Readable stream including a possible transform method.

    NOTE: When using a Stream to process change stream events, the stream will NOT automatically resume in the case a resumable error is encountered.

    throws

    MongoChangeStreamError if the underlying cursor or the change stream is closed

    Parameters

    Returns <internal>.Readable & <internal>.AsyncIterable<TChange>

  • removeAllListeners<EventKey>(event?: string | symbol | EventKey): ChangeStream<TSchema, TChange>
  • Type Parameters

    • EventKey extends "error" | "init" | "close" | "end" | "response" | "more" | "change" | "resumeTokenChanged"

    Parameters

    • Optional event: string | symbol | EventKey

    Returns ChangeStream<TSchema, TChange>

  • listeners<EventKey>(event: string | symbol | EventKey): ChangeStreamEvents<TSchema, TChange>[EventKey][]
  • Type Parameters

    • EventKey extends "error" | "init" | "close" | "end" | "response" | "more" | "change" | "resumeTokenChanged"

    Parameters

    • event: string | symbol | EventKey

    Returns ChangeStreamEvents<TSchema, TChange>[EventKey][]

  • rawListeners<EventKey>(event: string | symbol | EventKey): ChangeStreamEvents<TSchema, TChange>[EventKey][]
  • Type Parameters

    • EventKey extends "error" | "init" | "close" | "end" | "response" | "more" | "change" | "resumeTokenChanged"

    Parameters

    • event: string | symbol | EventKey

    Returns ChangeStreamEvents<TSchema, TChange>[EventKey][]

  • Type Parameters

    • EventKey extends "error" | "init" | "close" | "end" | "response" | "more" | "change" | "resumeTokenChanged"

    Parameters

    Returns boolean

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

    • EventKey extends "error" | "init" | "close" | "end" | "response" | "more" | "change" | "resumeTokenChanged"

    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
pipeline: <internal>.Document[]
namespace: MongoDBNamespace
type: symbol
streamOptions?: CursorStreamOptions

Events

RESPONSE: "response"
MORE: "more"
INIT: "init"
CLOSE: "close"
CHANGE: "change"

Fired for each new matching change in the specified namespace. Attaching a change event listener to a Change Stream will switch the stream into flowing mode. Data will then be passed as soon as it is available.

END: "end"
ERROR: "error"
RESUME_TOKEN_CHANGED: "resumeTokenChanged"

Emitted each time the change stream stores a new resume token.

Accessors

  • get resumeToken(): unknown
  • The cached resume token that is used to resume after the most recently returned change.

    Returns unknown

  • get closed(): boolean
  • Is the cursor closed

    Returns boolean

Generated using TypeDoc