MongoDB Cursor Methods
MongoDB provides a set of methods for managing collections, which allow you to perform operations such as creating, deleting, renaming, and listing collections. This page summarizes the collection methods in MongoDB.
-
cursor.addOption
The MongoDBaddOption()
method is used to add various options to the query for more flexible and efficient querying. -
cursor.allowDiskUse
TheallowDiskUse()
method is used by MongoDB to enable disk usage. -
cursor.allowPartialResults
TheallowPartialResults()
method allows partial query results to be returned in a query operation, even if some shards are faulty or unavailable. -
cursor.batchSize
batchSize()
is a method in MongoDB used to specify the number of documents returned per batch during batch processing. -
cursor.close
In MongoDB, theclose()
method is used to close an open connection or cursor. -
cursor.collation
The MongoDBcollation()
method is used to specify a certain sorting rule when querying data. -
cursor.comment
Thecomment()
method of MongoDB allows adding comments in query statements. -
cursor.count
Thecursor.count()
method is a MongoDB query method used to count the number of documents that match the query condition. -
cursor.explain
Thecursor.explain()
method in MongoDB is a tool used to explain the query plan, which can help developers view how MongoDB executes queries and optimize query performance. -
cursor.forEach
TheforEach()
method is one of the methods in MongoDB used to iterate over query results. -
cursor.hasNext
In MongoDB, thecursor.hasNext()
method is used to check if there is another document available in the cursor. -
cursor.hint
Thecursor.hint()
method specifies the index used for MongoDB queries. -
cursor.isClosed
cursor.isClosed()
is a cursor method in MongoDB that is used to check whether a cursor is closed or not. -
cursor.isExhausted
cursor.isExhausted()
is a cursor method in MongoDB that is used to determine whether the cursor has been fully traversed. -
cursor.itcount
cursor.itcount()
is a method in MongoDB that returns the number of documents in the query result. -
cursor.limit
The MongoDBcursor.limit()
method can limit the number of query results. -
cursor.map
The MongoDBmap()
method can map query results to a new array. -
cursor.max
Thecursor.max()
method in MongoDB is used to specify the maximum value of the query result. -
cursor.maxawaittimems
Thecursor.maxAwaitTimeMS()
method in MongoDB is used to set the maximum amount of time a query should wait, controlling the amount of time a query can wait before timing out. -
cursor.maxTimeMS
The MongoDBcursor.maxTimeMS()
method can set the maximum time (in milliseconds) for an operation, and the operation will be forcibly terminated if it exceeds this time. -
cursor.min
Thecursor.min()
method is a very useful method that can find the minimum value of a specified field. -
cursor.next
The MongoDBcursor.next()
method is a very useful method that can return the next document in the cursor. -
cursor.noCursorTimeout
The MongoDBcursor.noCursorTimeout()
method can effectively control the timeout time of query cursor. -
cursor.objsLeftInBatch
Thecursor.objsLeftInBatch()
method in MongoDB is used to check if there are any unprocessed documents remaining in the query results. -
cursor.pretty
The MongoDBcursor.pretty()
method can be used to format the results for easier readability and understanding. -
cursor.readConcern
The MongoDBcursor.readConcern()
method is used to set the read concern level for the query. -
cursor.readPref
The MongoDBcursor.readPref()
method is used to set the preference for reading data. -
cursor.returnKey
cursor.returnKey()
is a method in MongoDB that allows returning only the keys of matching documents in a query instead of the whole document itself. -
cursor.showRecordId
Thecursor.showRecordId()
method allows the_id
field value of each record to be included in the query results, making it easy for us to view the unique identifier of each record. -
cursor.size
In MongoDB, thecursor.size()
method is used to return the number of documents that match a query. -
cursor.skip
In MongoDB, thecursor.skip()
method can be used to skip the first N documents in a query result and return the subsequent documents. -
cursor.sort
The MongoDBsort()
method is used to sort query results and can sort in ascending or descending order based on the specified field. -
cursor.tailable
Thecursor.tailable()
method is used in MongoDB to obtain a cursor, which returns an iterable result set that can be used to implement features similar to “continuous listening,” where newly added data can be obtained in real-time. -
cursor.toArray
In MongoDB, thecursor.toArray()
method is used to return all documents returned by a cursor as an array. -
cursor.tryNext
The MongoDBcursor.tryNext()
method is used to retrieve the next document in a cursor.