Cursor MethodsΒΆ

Name Description
cursor.addOption() Adds special wire protocol flags that modify the behavior of the query.’
cursor.batchSize() Controls the number of documents MongoDB will return to the client in a single network message.
cursor.count() Returns a count of the documents in a cursor.
cursor.explain() Reports on the query execution plan, including index use, for a cursor.
cursor.forEach() Applies a JavaScript function for every document in a cursor.
cursor.hasNext() Returns true if the cursor has documents and can be iterated.
cursor.hint() Forces MongoDB to use a specific index for a query.
cursor.limit() Constrains the size of a cursor’s result set.
cursor.map() Applies a function to each document in a cursor and collects the return values in an array.
cursor.max() Specifies an exclusive upper index bound for a cursor. For use with cursor.hint()
cursor.min() Specifies an inclusive lower index bound for a cursor. For use with cursor.hint()
cursor.next() Returns the next document in a cursor.
cursor.objsLeftInBatch() Returns the number of documents left in the current cursor batch.
cursor.readPref() Specifies a read preference to a cursor to control how the client directs queries to a replica set.
cursor.showDiskLoc() Returns a cursor with modified documents that include the on-disk location of the document.
cursor.size() Returns a count of the documents in the cursor after applying skip() and limit() methods.
cursor.skip() Returns a cursor that begins returning results only after passing or skipping a number of documents.
cursor.snapshot() Forces the cursor to use the index on the _id field. Ensures that the cursor returns each document, with regards to the value of the _id field, only once.
cursor.sort() Returns results ordered according to a sort specification.
cursor.toArray() Returns an array that contains all documents returned by the cursor.

MongoDB Manual 2.4

Formats

About MongoDB

MongoDB Ecosystem

MongoDB Resources