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.

  1. cursor.addOption

    The MongoDB addOption() method is used to add various options to the query for more flexible and efficient querying.
  2. cursor.allowDiskUse

    The allowDiskUse() method is used by MongoDB to enable disk usage.
  3. cursor.allowPartialResults

    The allowPartialResults() method allows partial query results to be returned in a query operation, even if some shards are faulty or unavailable.
  4. cursor.batchSize

    batchSize() is a method in MongoDB used to specify the number of documents returned per batch during batch processing.
  5. cursor.close

    In MongoDB, the close() method is used to close an open connection or cursor.
  6. cursor.collation

    The MongoDB collation() method is used to specify a certain sorting rule when querying data.
  7. cursor.comment

    The comment() method of MongoDB allows adding comments in query statements.
  8. cursor.count

    The cursor.count() method is a MongoDB query method used to count the number of documents that match the query condition.
  9. cursor.explain

    The cursor.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.
  10. cursor.forEach

    The forEach() method is one of the methods in MongoDB used to iterate over query results.
  11. cursor.hasNext

    In MongoDB, the cursor.hasNext() method is used to check if there is another document available in the cursor.
  12. cursor.hint

    The cursor.hint() method specifies the index used for MongoDB queries.
  13. cursor.isClosed

    cursor.isClosed() is a cursor method in MongoDB that is used to check whether a cursor is closed or not.
  14. cursor.isExhausted

    cursor.isExhausted() is a cursor method in MongoDB that is used to determine whether the cursor has been fully traversed.
  15. cursor.itcount

    cursor.itcount() is a method in MongoDB that returns the number of documents in the query result.
  16. cursor.limit

    The MongoDB cursor.limit() method can limit the number of query results.

    The MongoDB map() method can map query results to a new array.
  18. cursor.max

    The cursor.max() method in MongoDB is used to specify the maximum value of the query result.
  19. cursor.maxawaittimems

    The cursor.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.
  20. cursor.maxTimeMS

    The MongoDB cursor.maxTimeMS() method can set the maximum time (in milliseconds) for an operation, and the operation will be forcibly terminated if it exceeds this time.
  21. cursor.min

    The cursor.min() method is a very useful method that can find the minimum value of a specified field.

    The MongoDB method is a very useful method that can return the next document in the cursor.
  23. cursor.noCursorTimeout

    The MongoDB cursor.noCursorTimeout() method can effectively control the timeout time of query cursor.
  24. cursor.objsLeftInBatch

    The cursor.objsLeftInBatch() method in MongoDB is used to check if there are any unprocessed documents remaining in the query results.
  25. cursor.pretty

    The MongoDB cursor.pretty() method can be used to format the results for easier readability and understanding.
  26. cursor.readConcern

    The MongoDB cursor.readConcern() method is used to set the read concern level for the query.
  27. cursor.readPref

    The MongoDB cursor.readPref() method is used to set the preference for reading data.
  28. 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.
  29. cursor.showRecordId

    The cursor.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.
  30. cursor.size

    In MongoDB, the cursor.size() method is used to return the number of documents that match a query.
  31. cursor.skip

    In MongoDB, the cursor.skip() method can be used to skip the first N documents in a query result and return the subsequent documents.
  32. cursor.sort

    The MongoDB sort() method is used to sort query results and can sort in ascending or descending order based on the specified field.
  33. cursor.tailable

    The cursor.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.
  34. cursor.toArray

    In MongoDB, the cursor.toArray() method is used to return all documents returned by a cursor as an array.
  35. cursor.tryNext

    The MongoDB cursor.tryNext() method is used to retrieve the next document in a cursor.