Promise
Manage access to data, be it to find, update or remove it.
It extends Promise so that its methods are chainable & awaitable.
**Kind**: global class **Extends**:Promise
* [Cursor](#Cursor) ⇐ Promise
* [new Cursor(db, query, [execFn], [async])](#new_Cursor_new)
* _instance_
* [.limit(limit)](#Cursor+limit) ⇒ [Cursor
](#Cursor)
* [.skip(skip)](#Cursor+skip) ⇒ [Cursor
](#Cursor)
* [.sort(sortQuery)](#Cursor+sort) ⇒ [Cursor
](#Cursor)
* [.projection(projection)](#Cursor+projection) ⇒ [Cursor
](#Cursor)
* [.project(candidates)](#Cursor+project) ⇒ [Array.<document>
](#document)
* [._execAsync()](#Cursor+_execAsync) ⇒ [Array.<document>
](#document) \| Promise.<\*>
* [._exec(_callback)](#Cursor+_exec)
* [.exec(_callback)](#Cursor+exec)
* [.execAsync()](#Cursor+execAsync) ⇒ Promise.<(Array.<document>\|\*)>
* _inner_
* [~execFn](#Cursor..execFn) : function
* [~execFnAsync](#Cursor..execFnAsync) ⇒ Promise
* [~execCallback](#Cursor..execCallback) : function
### new Cursor(db, query, [execFn], [async])
Create a new cursor for this collection
| Param | Type | Default | Description | | --- | --- | --- | --- | | db | [Datastore
](#Datastore) | | The datastore this cursor is bound to
| | query | [query
](#query) | | The query this cursor will operate on
| | [execFn] | [execFn
](#Cursor..execFn) \| [execFnAsync
](#Cursor..execFnAsync) | | Handler to be executed after cursor has found the results and before the callback passed to find/findOne/update/remove
| | [async] |boolean
| false
| If true, specifies that the execFn
is of type [execFnAsync](#Cursor..execFnAsync) rather than [execFn](#Cursor..execFn).
Cursor
](#Cursor)
Set a limit to the number of results
**Kind**: instance method of [Cursor
](#Cursor)
| Param | Type |
| --- | --- |
| limit | Number
|
### cursor.skip(skip) ⇒ [Cursor
](#Cursor)
Skip a number of results
**Kind**: instance method of [Cursor
](#Cursor)
| Param | Type |
| --- | --- |
| skip | Number
|
### cursor.sort(sortQuery) ⇒ [Cursor
](#Cursor)
Sort results of the query
**Kind**: instance method of [Cursor
](#Cursor)
| Param | Type | Description |
| --- | --- | --- |
| sortQuery | Object.<string, number>
| sortQuery is { field: order }, field can use the dot-notation, order is 1 for ascending and -1 for descending
| ### cursor.projection(projection) ⇒ [Cursor
](#Cursor)
Add the use of a projection
**Kind**: instance method of [Cursor
](#Cursor)
| Param | Type | Description |
| --- | --- | --- |
| projection | Object.<string, number>
| MongoDB-style projection. {} means take all fields. Then it's { key1: 1, key2: 1 } to take only key1 and key2 { key1: 0, key2: 0 } to omit only key1 and key2. Except _id, you can't mix takes and omits.
| ### cursor.project(candidates) ⇒ [Array.<document>
](#document)
Apply the projection
**Kind**: instance method of [Cursor
](#Cursor)
| Param | Type |
| --- | --- |
| candidates | [Array.<document>
](#document) |
### cursor.\_execAsync() ⇒ [Array.<document>
](#document) \| Promise.<\*>
Get all matching elements Will return pointers to matched elements (shallow copies), returning full copies is the role of find or findOne This is an internal function, use execAsync which uses the executor
**Kind**: instance method of [Cursor
](#Cursor)
### cursor.\_exec(_callback)
Get all matching elements Will return pointers to matched elements (shallow copies), returning full copies is the role of find or findOne This is an internal function, use exec which uses the executor
**Kind**: instance method of [Cursor
](#Cursor)
| Param | Type |
| --- | --- |
| _callback | [execCallback
](#Cursor..execCallback) |
### cursor.exec(_callback)
Get all matching elements Will return pointers to matched elements (shallow copies), returning full copies is the role of find or findOne
**Kind**: instance method of [Cursor
](#Cursor)
| Param | Type |
| --- | --- |
| _callback | [execCallback
](#Cursor..execCallback) |
### cursor.execAsync() ⇒ Promise.<(Array.<document>\|\*)>
Get all matching elements Will return pointers to matched elements (shallow copies), returning full copies is the role of find or findOne
**Kind**: instance method of [Cursor
](#Cursor)
### Cursor~execFn : function
**Kind**: inner typedef of [Cursor
](#Cursor)
| Param | Type |
| --- | --- |
| err | Error
|
| res | [?Array.<document>
](#document) \| [document
](#document) |
### Cursor~execFnAsync ⇒ Promise
**Kind**: inner typedef of [Cursor
](#Cursor)
| Param | Type |
| --- | --- |
| res | [?Array.<document>
](#document) \| [document
](#document) |
### Cursor~execCallback : function
**Kind**: inner typedef of [Cursor
](#Cursor)
| Param | Type | Description |
| --- | --- | --- |
| err | Error
| |
| res | [Array.<document>
](#document) \| \*
| If an execFn was given to the Cursor, then the type of this parameter is the one returned by the execFn.
|