Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ChangeStream<TSchema>

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

Type parameters

Hierarchy

Index

Constructors

constructor

Events

Static Readonly CHANGE

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.

Static Readonly CLOSE

CLOSE: "close" = ...

Static Readonly END

END: "end" = ...

Static Readonly ERROR

ERROR: "error" = ...

Static Readonly INIT

INIT: "init" = ...

Static Readonly MORE

MORE: "more" = ...

Static Readonly RESPONSE

RESPONSE: "response" = ...

Static Readonly RESUME_TOKEN_CHANGED

RESUME_TOKEN_CHANGED: "resumeTokenChanged" = ...

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

Properties

[kClosed]

[kClosed]: boolean
internal

Optional [kCursorStream]

[kCursorStream]: Readable
internal

[kMode]

[kMode]: false | "iterator" | "emitter"
internal

[kResumeQueue]

[kResumeQueue]: Denque<any>
internal

Optional cursor

cursor: ChangeStreamCursor<TSchema>
internal

namespace

namespace: MongoDBNamespace

options

parent

pipeline

pipeline: Document[]

Optional streamOptions

streamOptions: CursorStreamOptions

type

type: symbol

Static Readonly captureRejectionSymbol

captureRejectionSymbol: typeof captureRejectionSymbol

Static captureRejections

captureRejections: boolean

Sets or gets the default captureRejection value for all emitters.

Static defaultMaxListeners

defaultMaxListeners: number

Static Readonly errorMonitor

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.

Accessors

closed

  • get closed(): boolean

cursorStream

  • get cursorStream(): undefined | Readable

resumeToken

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

    Returns unknown

Methods

addListener

close

  • close(callback?: Callback<any>): void | Promise<void>

emit

  • emit<EventKey>(event: symbol | EventKey, ...args: Parameters<ChangeStreamEvents[EventKey]>): boolean

eventNames

  • eventNames(): string[]

getMaxListeners

  • getMaxListeners(): number

hasNext

  • hasNext(callback?: Callback<any>): void | Promise<void>
  • Check if there is any document still available in the Change Stream

    Parameters

    Returns void | Promise<void>

listenerCount

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

listeners

next

off

on

once

prependListener

prependOnceListener

rawListeners

  • rawListeners<EventKey>(event: string | symbol | EventKey): ChangeStreamEvents[EventKey][]

removeAllListeners

  • removeAllListeners<EventKey>(event?: string | symbol | EventKey): ChangeStream<TSchema>

removeListener

setMaxListeners

stream

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

    throws

    MongoDriverError if this.cursor is undefined

    Parameters

    Returns Readable

tryNext

Static getEventListener

  • getEventListener(emitter: DOMEventTarget | EventEmitter, name: string | symbol): Function[]
  • Returns a list listener for a specific emitter event name.

    Parameters

    • emitter: DOMEventTarget | EventEmitter
    • name: string | symbol

    Returns Function[]

Static listenerCount

  • listenerCount(emitter: EventEmitter, event: string | symbol): number
  • deprecated

    since v4.0.0

    Parameters

    • emitter: EventEmitter
    • event: string | symbol

    Returns number

Static on

  • on(emitter: EventEmitter, event: string, options?: StaticEventEmitterOptions): AsyncIterableIterator<any>
  • Parameters

    • emitter: EventEmitter
    • event: string
    • Optional options: StaticEventEmitterOptions

    Returns AsyncIterableIterator<any>

Static once

  • once(emitter: NodeEventTarget, event: string | symbol, options?: StaticEventEmitterOptions): Promise<any[]>
  • once(emitter: DOMEventTarget, event: string, options?: StaticEventEmitterOptions): Promise<any[]>
  • Parameters

    • emitter: NodeEventTarget
    • event: string | symbol
    • Optional options: StaticEventEmitterOptions

    Returns Promise<any[]>

  • Parameters

    • emitter: DOMEventTarget
    • event: string
    • Optional options: StaticEventEmitterOptions

    Returns Promise<any[]>

Generated using TypeDoc