Global

Methods

getCursor(changeStream, callback, oldCursor)

Safely provides a cursor across resume attempts

Name Type Description
changeStream ChangeStream

the parent ChangeStream

callback function

gets the cursor or error

oldCursor ChangeStreamCursor optional

when resuming from an error, carry over options from previous cursor

processResumeQueue(changeStream, err)

Drain the resume queue when a new has become available

Name Type Description
changeStream ChangeStream

the parent ChangeStream

Name Type Description
cursor ChangeStreamCursor nullable

the new cursor

err Error optional

error getting a new cursor

Type Definitions

ChangeStreamOptions

Options that can be passed to a ChangeStream. Note that startAfter, resumeAfter, and startAtOperationTime are all mutually exclusive, and the server will error if more than one is specified.

Properties:
Name Type Argument Default Description
fullDocument string <optional>
'default'

Allowed values: ‘default’, ‘updateLookup’. When set to ‘updateLookup’, the change stream will include both a delta describing the changes to the document, as well as a copy of the entire document that was changed from some time after the change occurred.

maxAwaitTimeMS number <optional>

The maximum amount of time for the server to wait on new documents to satisfy a change stream query.

resumeAfter ResumeToken <optional>

Allows you to start a changeStream after a specified event. See ChangeStream documentation.

startAfter ResumeToken <optional>

Similar to resumeAfter, but will allow you to start after an invalidated event. See ChangeStream documentation.

startAtOperationTime OperationTime <optional>

Will start the changeStream after the specified operationTime.

batchSize number <optional>
1000

The number of documents to return per batch. See aggregation documentation.

collation object <optional>

Specify collation settings for operation. See aggregation documentation.

readPreference ReadPreference <optional>

The read preference. Defaults to the read preference of the database or collection. See read preference documentation.

DriverInfoOptionsObject

Configuration options for drivers wrapping the node driver.

Properties:
Name Type Argument Description
name string <optional>

The name of the driver

version string <optional>

The version of the driver

platform string <optional>

Optional platform information

DriverInfoOptionsObject

Configuration options for drivers wrapping the node driver.

Properties:
Name Type Argument Description
name string <optional>

The name of the driver

version string <optional>

The version of the driver

platform string <optional>

Optional platform information

KMSProvidersobject

Configuration options that are used by specific KMS providers during key generation, encryption, and decryption.

Properties:
Name Type Argument Description
aws object <optional>

Configuration options for using 'aws' as your KMS provider

Properties
Name Type Argument Description
accessKeyId string <optional>

The access key used for the AWS KMS provider

secretAccessKey string <optional>

The secret access key used for the AWS KMS provider

local object <optional>

Configuration options for using 'local' as your KMS provider

Properties
Name Type Argument Description
key Buffer <optional>

The master key used to encrypt/decrypt data keys. A 96-byte long Buffer.

OperationTime

Represents a specific point in time on a server. Can be retrieved by using Db#command

See:

ReadConcernObject

The MongoDB ReadConcern, which allows for control of the consistency and isolation properties
of the data read from replica sets and replica set shards.

Properties:
Name Type Description
level 'local' | 'available' | 'majority' | 'linearizable' | 'snapshot'

The readConcern Level

See:

ReadConcernLevel'local' 'available' 'majority' 'linearizable' 'snapshot'

A string specifying the level of a ReadConcern

See:

ResumeToken

Represents the logical starting point for a new or resuming ChangeStream on the server.

See:

SessionIdObject

A BSON document reflecting the lsid of a ClientSession

SessionOptionsObject

Options to pass when creating a Client Session

Properties:
Name Type Argument Default Description
causalConsistency boolean <optional>
true

Whether causal consistency should be enabled on this session

defaultTransactionOptions TransactionOptions <optional>

The default TransactionOptions to use for transactions started on this session.

TransactionOptionsObject

Configuration options for a transaction.

Properties:
Name Type Argument Description
readConcern ReadConcern <optional>

A default read concern for commands in this transaction

writeConcern WriteConcern <optional>

A default writeConcern for commands in this transaction

readPreference ReadPreference <optional>

A default read preference for commands in this transaction

WithTransactionCallback(session){Promise}

A user provided function to be run within a transaction

Name Type Description
session ClientSession

The parent session of the transaction running the operation. This should be passed into each operation within the lambda.

Returns:
resulting Promise of operations run within this transaction

WriteConcernObject

A MongoDB WriteConcern, which describes the level of acknowledgement
requested from MongoDB for write operations.

Properties:
Name Type Argument Default Description
w number | 'majority' | string <optional>
1

requests acknowledgement that the write operation has
propagated to a specified number of mongod hosts

j boolean <optional>
false

requests acknowledgement from MongoDB that the write operation has
been written to the journal

wtimeout number <optional>

a time limit, in milliseconds, for the write concern

See: