Class: Cursor

Cursor(collection, docs, selector)

Represents a Mongo.Cursor, usually returned by Collection.find().

Constructor

new Cursor(collection, docs, selector)

Usually you don't use this directly, unless you know what you are doing.
Parameters:
Name Type Description
collection
docs
selector
Source:
See:

Methods

count() → {number}

Returns the number of documents that match a query. This method is deprecated since MongoDB 4.0 and will soon be replaced by Collection.countDocuments and Collection.estimatedDocumentCount.
Deprecated:
  • Yes
Source:
Returns:
size of the collection
Type
number

fetch() → {Array.<object>}

Return all matching documents as an Array.
Source:
Returns:
Type
Array.<object>

forEach(callback)

Call callback once for each matching document, sequentially and synchronously.
Parameters:
Name Type Description
callback function Function to call. It will be called with three arguments: the document, a 0-based index, and cursor itself.
Source:

map(callback) → {Array.<object>}

Map callback over all matching documents. Returns an Array.
Parameters:
Name Type Description
callback function Function to call. It will be called with three arguments: the document, a 0-based index, and cursor itself.
Source:
Returns:
Type
Array.<object>

observe(callbacks)

Registers an observer for the given callbacks
Parameters:
Name Type Description
callbacks object
Source:
See: