Class: Cursor

Cursor

new Cursor(bson, ns, cmd, options, topology, topologyOptions){Cursor}

Creates a new Cursor, not to be used directly

Name Type Default Description
bson object

An instance of the BSON parser

ns string

The MongoDB fully qualified namespace (ex: db1.collection1)

cmd Object | Long

The selector (can be a command or a cursorId)

options object null optional

Optional settings.

Name Type Default Description
batchSize object 1000 optional

Batchsize for the operation

documents array [] optional

Initial documents list for cursor

transforms object null optional

Transform methods for the cursor results

Name Type Description
query function optional

Transform the value returned from the initial query

doc function optional

Transform each document returned from Cursor.prototype.next

topology object

The server topology instance.

topologyOptions object

The server topology options.

Properties:
Name Type Description
cursorBatchSize number

The current cursorBatchSize for the cursor

cursorLimit number

The current cursorLimit for the cursor

cursorSkip number

The current cursorSkip for the cursor

Returns:
cursor instance

Methods

bufferedCount(){number}

Returns current buffered documents length

Returns:
number of items in the buffered documents

Clone the cursor

isDead(){boolean}

Checks if the cursor is dead

Returns:
boolean signifying if the cursor is dead or not

isKilled(){boolean}

Checks if the cursor was killed by the application

Returns:
boolean signifying if the cursor was killed by the application

isNotified(){boolean}

Checks if the cursor notified it's caller about it's death

Returns:
boolean signifying if the cursor notified the callback

kill(callback)

Kill the cursor

Name Type Description
callback resultCallback

A callback function

next(callback)

Retrieve the next document from the cursor

Name Type Description
callback resultCallback

A callback function

readBufferedDocuments(){Array}

Returns current buffered documents

Returns:
array of buffered documents

rewind(){null}

Resets the cursor