Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ClientSession

A class representing a client session on the server

NOTE: not meant to be instantiated directly.

Hierarchy

Index

Constructors

constructor

Properties

Optional [kServerSession]

[kServerSession]: ServerSession
internal

[kSnapshotEnabled]

[kSnapshotEnabled]: boolean = false
internal

Optional [kSnapshotTime]

[kSnapshotTime]: Timestamp
internal

Optional clientOptions

clientOptions: MongoOptions

Optional clusterTime

clusterTime: ClusterTime

defaultTransactionOptions

defaultTransactionOptions: TransactionOptions

explicit

explicit: boolean

hasEnded

hasEnded: boolean

Optional operationTime

operationTime: Timestamp

Optional owner

owner: symbol | AbstractCursor<any, AbstractCursorEvents>
internal

sessionPool

sessionPool: ServerSessionPool
internal

supports

supports: { causalConsistency: boolean }

Type declaration

  • causalConsistency: boolean

topology

topology: Topology
internal

transaction

transaction: Transaction

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

id

serverSession

snapshotEnabled

  • get snapshotEnabled(): boolean
  • Whether or not this session is configured for snapshot reads

    Returns boolean

Methods

abortTransaction

addListener

advanceOperationTime

  • advanceOperationTime(operationTime: Timestamp): void
  • Advances the operationTime for a ClientSession.

    Parameters

    • operationTime: Timestamp

      the BSON.Timestamp of the operation type it is desired to advance to

    Returns void

commitTransaction

emit

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

endSession

  • endSession(): Promise<void>
  • endSession(callback: Callback<void>): void
  • endSession(options: Record<string, unknown>): Promise<void>
  • endSession(options: Record<string, unknown>, callback: Callback<void>): void

equals

eventNames

  • eventNames(): string[]

getMaxListeners

  • getMaxListeners(): number

inTransaction

  • inTransaction(): boolean
  • Returns boolean

    whether this session is currently in a transaction or not

incrementTransactionNumber

  • incrementTransactionNumber(): void
  • Increment the transaction number on the internal ServerSession

    Returns void

listenerCount

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

listeners

off

on

once

prependListener

prependOnceListener

rawListeners

removeAllListeners

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

removeListener

setMaxListeners

startTransaction

toBSON

  • toBSON(): never
  • This is here to ensure that ClientSession is never serialized to BSON.

    Returns never

withTransaction

  • Runs a provided lambda within a transaction, retrying either the commit operation or entire transaction as needed (and when the error permits) to better ensure that the transaction can complete successfully.

    IMPORTANT: This method requires the user to return a Promise, all lambdas that do not return a Promise will result in undefined behavior.

    Type parameters

    • T = void

    Parameters

    Returns Promise<T>

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