,
line 64Creates a new Cursor instance (INTERNAL TYPE, do not instantiate directly)
sortValue
string
Cursor query sort setting.
timeout
boolean
Is Cursor able to time out.
readPreference
ReadPreference
Get cursor ReadPreference.
Cursor cursor options.
collection.find({}).project({a:1}) // Create a projection of field a
collection.find({}).skip(1).limit(10) // Skip 1 and limit 10
collection.find({}).batchSize(5) // Set batchSize on cursor to 5
collection.find({}).filter({a:1}) // Set query on the cursor
collection.find({}).comment('add a comment') // Add a comment to the query, allowing to correlate queries
collection.find({}).addCursorFlag('tailable', true) // Set cursor as tailable
collection.find({}).addCursorFlag('noCursorTimeout', true) // Set cursor as noCursorTimeout
collection.find({}).addCursorFlag('awaitData', true) // Set cursor as awaitData
collection.find({}).addCursorFlag('partial', true) // Set cursor as partial
collection.find({}).addQueryModifier('$orderby', {a:1}) // Set $orderby {a:1}
collection.find({}).max(10) // Set the cursor max
collection.find({}).maxTimeMS(1000) // Set the cursor maxTimeMS
collection.find({}).min(100) // Set the cursor min
collection.find({}).returnKey(true) // Set the cursor returnKey
collection.find({}).setReadPreference(ReadPreference.PRIMARY) // Set the cursor readPreference
collection.find({}).showRecordId(true) // Set the cursor showRecordId
collection.find({}).sort([['a', 1]]) // Sets the sort order of the cursor query
collection.find({}).hint('a_1') // Set the cursor hint
All options are chainable, so one can do the following.
collection.find({}).maxTimeMS(1000).maxScan(100).skip(1).toArray(..)
,
line 412Add a cursor flag to the cursor
Name Type Descriptionflag
string
The flag to set, must be one of following ['tailable', 'oplogReplay', 'noCursorTimeout', 'awaitData', 'partial'].
value
boolean
The flag boolean value.
,
line 440Add a query modifier to the cursor query
Name Type Descriptionname
string
The query modifier (must start with $, such as $orderby etc)
value
string | boolean | number
The modifier value.
,
line 587Set the batch size for the cursor.
Name Type Descriptionvalue
number
The number of documents to return per batch. See find command documentation.
,
line 677Clone the cursor
,
line 912Close the cursor, sending a KillCursor command and emitting close.
Name Type Descriptionoptions
object optional
Optional settings.
Name Type DescriptionskipKillCursors
boolean optional
Bypass calling killCursors when closing the cursor.
callback
Cursor~resultCallback optional
The result callback.
,
line 615Set the collation options for the cursor.
Name Type Descriptionvalue
object
The cursor collation options (MongoDB 3.4 or higher) settings for update operation (see 3.4 documentation for available fields).
,
line 465Add a comment to the cursor query allowing for tracking the comment in the log.
Name Type Descriptionvalue
string
The comment attached to this query.
,
line 881Get the count of documents for this cursor
Name Type Default DescriptionapplySkipLimit
boolean true optional
Should the count command apply limit and skip settings on the cursor or in the passed in options.
options
object optional
Optional settings.
Name Type Descriptionskip
number optional
The number of documents to skip.
limit
number optional
The maximum amounts to count before aborting.
maxTimeMS
number optional
Number of milliseconds to wait before aborting the query.
hint
string optional
An index name hint for the query.
readPreference
ReadPreference | string optional
The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST).
callback
Cursor~countResultCallback optional
The result callback.
,
line 702Iterates over all the documents for this cursor. As with {cursor.toArray},
not all of the elements will be iterated if this cursor had been previously accessed.
In that case, {cursor.rewind} can be used to reset the cursor. However, unlike
{cursor.toArray}, the cursor will only hold a maximum of batch size elements
at any given time if batch size is specified. Otherwise, the caller is responsible
for making sure that the entire result can fit the memory.
callback
Cursor~resultCallback
The result callback.
,
line 1014Execute the explain for the cursor
For backwards compatibility, a verbosity of true is interpreted as "allPlansExecution"
and false as "queryPlanner". Prior to server version 3.6, aggregate()
ignores the verbosity parameter and executes in "queryPlanner".
verbosity
'queryPlanner' | 'queryPlannerExtended' | 'executionStats' | 'allPlansExecution' | boolean true optional
An optional mode in which to run the explain.
callback
Cursor~resultCallback optional
The result callback.
,
line 263Set the cursor query
Name Type Descriptionfilter
object
The filter object used for the cursor.
,
line 731Iterates over all the documents for this cursor using the iterator, callback pattern.
Name Type Descriptioniterator
Cursor~iteratorCallback
The iteration callback.
callback
Cursor~endCallback
The end callback.
,
line 196Check if there is any document still available in the cursor
Name Type Descriptioncallback
Cursor~resultCallback optional
The result callback.
,
line 294Set the cursor hint
Name Type Descriptionhint
object
If specified, then the query system will only consider plans using the hinted index.
,
line 954Is the cursor closed
,
line 627Set the limit for the cursor.
Name Type Descriptionvalue
number
The limit for the cursor query.
,
line 936Map all documents using the provided function
Name Type Descriptiontransform
function optional
The mapping transformation method.
,
line 324Set the cursor max
Name Type Descriptionmax
object
Specify a $max value to specify the exclusive upper bound for a specific index in order to constrain the results of find(). The $max specifies the upper bound for all keys of a specific index in order.
,
line 481Set a maxAwaitTimeMS on a tailing cursor query to allow to customize the timeout value for the option awaitData (Only supported on MongoDB 3.2 or higher, ignored otherwise)
Name Type Descriptionvalue
number
Number of milliseconds to wait before aborting the tailed query.
,
line 279Set the cursor maxScan
Name Type DescriptionmaxScan
object
Constrains the query to only scan the specified number of documents when fulfilling the query
,
line 501Set a maxTimeMS on the cursor query, allowing for hard timeout limits on queries (Only supported on MongoDB 2.6 or higher)
Name Type Descriptionvalue
number
Number of milliseconds to wait before aborting the query.
,
line 309Set the cursor min
Name Type Descriptionmin
object
Specify a $min value to specify the inclusive lower bound for a specific index in order to constrain the results of find(). The $min specifies the lower bound for all keys of a specific index in order.
,
line 233Get the next available document from the cursor, returns null if no more documents are available.
Name Type Descriptioncallback
Cursor~resultCallback optional
The result callback.
,
line 1102This method will cause a stream in flowing-mode to stop emitting data events. Any data that becomes available will remain in the internal buffer.
,
line 1108This method pulls all the data out of a readable stream, and writes it to the supplied destination, automatically managing the flow so that the destination is not overwhelmed by a fast readable stream.
Name Type Descriptiondestination
Writable
The destination for writing data
options
object optional
Pipe options
,
line 521Sets a field projection for the query.
Name Type Descriptionvalue
object
The field projection object.
,
line 1082The read() method pulls some data out of the internal buffer and returns it. If there is no data available, then it will return null.
Name Type Descriptionsize
number
Optional argument to specify how much data to read.
,
line 1096This method will cause the readable stream to resume emitting data events.
,
line 339Set the cursor returnKey. If set to true, modifies the cursor to only return the index field or fields for the results of the query, rather than documents. If set to true and the query does not use an index to perform the read operation, the returned documents will not contain any fields.
Name Type DescriptionreturnKey
bool
the returnKey value.
,
line 683Resets the cursor
,
line 387Set a node.js specific cursor option
Name Type Descriptionfield
string
The cursor option to set ['numberOfRetries', 'tailableRetryInterval'].
value
object
The field value.
,
line 1089Call this function to cause the stream to return strings of the specified encoding instead of Buffer objects.
Name Type Descriptionencoding
string
The encoding to use.
,
line 780Set the ReadPreference for the cursor.
Name Type DescriptionreadPreference
string | ReadPreference
The new read preference for the cursor.
,
line 354Set the cursor showRecordId
Name Type DescriptionshowRecordId
object
The $showDiskLoc option has now been deprecated and replaced with the showRecordId field. $showDiskLoc will still be accepted for OP_QUERY stye find.
,
line 652Set the skip for the cursor.
Name Type Descriptionvalue
number
The skip for the cursor query.
,
line 370Set the cursor snapshot
Name Type Descriptionsnapshot
object
The $snapshot operator prevents the cursor from returning a document more than once because an intervening write operation results in a move of the document.
,
line 538Sets the sort order of the cursor query.
Name Type DescriptionkeyOrList
string | array | object
The key or keys set for the sort.
direction
number optional
The direction of the sorting (1 or -1).
,
line 972Return a modified Readable stream including a possible transform method.
Name Type Descriptionoptions
object optional
Optional settings.
Name Type Descriptiontransform
function optional
A transformation method applied to each document emitted by the stream.
,
line 816Returns an array of documents. The caller is responsible for making sure that there
is enough memory to store the results. Note that the array only contains partial
results when this cursor had been previously accessed. In that case,
cursor.rewind() can be used to reset the cursor.
callback
Cursor~toArrayResultCallback optional
The result callback.
,
line 985Return a modified Readable stream that applies a given transform function, if supplied. If none supplied,
returns a stream of unmodified docs.
options
object optional
Optional settings.
Name Type Descriptiontransform
function optional
A transformation method applied to each document emitted by the stream.
,
line 1116This method will remove the hooks set up for a previous pipe() call.
Name Type Descriptiondestination
Writable optional
The destination for writing data
,
line 1123This is useful in certain cases where a stream is being consumed by a parser, which needs to "un-consume" some data that it has optimistically pulled out of the source, so that the stream can be passed on to some other party.
Name Type Descriptionchunk
Buffer | string
Chunk of data to unshift onto the read queue.
,
line 1130Versions of Node prior to v0.10 had streams that did not implement the entire Streams API as it is today. (See "Compatibility" below for more information.)
Name Type Descriptionstream
Stream
An "old style" readable stream.
,
line 861The callback format for results
Name Type Descriptionerror
MongoError
An error instance representing the error during the execution.
count
number
The count of documents.
,
line 717The callback error format for the forEach iterator method
Name Type Descriptionerror
MongoError
An error instance representing the error during the execution.
,
line 711The callback format for the forEach iterator method
Name Type Descriptiondoc
Object
An emitted document for the iterator
,
line 670The callback format for results
Name Type Descriptionerror
MongoError
An error instance representing the error during the execution.
result
object | null | boolean
The result object if the command was executed successfully.
,
line 799The callback format for results
Name Type Descriptionerror
MongoError
An error instance representing the error during the execution.
documents
Array.<object>
All the documents the satisfy the cursor.
,
line 1053Cursor stream close event
Type:,
line 1039Cursor stream data event, fired for each document in the cursor.
Type:,
line 1046Cursor stream end event
Type:,
line 1060Cursor stream readable event
Type:RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4