MongoDB is an open-source database management system that uses the NoSql database to store large amounts of data. MongoDB uses collection and documents instead of tables like traditional relational databases. MongoDB documents are similar to JSON objects but use a variant called Binary JSON (BSON) that accommodates more data types.
What is a Cursor?
When you use the function
db.collection.find() to search documents in collections than as a result it returns a pointer. That pointer is known as a cursor. Consider if we have 2 documents in our collection, then cursor object will point to the first document and then iterate through all documents which are present in our collection.
As we already discussed what is a cursor. It is basically a tool for iterating over MongoDB queries. This cursor instance is returned by the find() method. Consider the below example for better understanding.
In this, find() method returns the cursor object.
lectures = db.lecture.find()
With the next() method we get the next document in the collection.
list() method, we can transform the cursor to a Python list.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
- Convert PyMongo Cursor to JSON
- Convert PyMongo Cursor to Dataframe
- How to check if the PyMongo Cursor is Empty?
- Get the Names of all Collections using PyMongo
- Update all Documents in a Collection using PyMongo
- Difference Between insert(), insertOne(), and insertMany() in Pymongo
- Get all the information of a Collection's indexes using PyMongo
- How to rebuild all the indexes of a collection using PyMongo?
- Nested Queries in PyMongo
- Get all the Documents of the Collection using PyMongo
- How to Drop all the indexes in a Collection using PyMongo?
- PyQt5 QSpinBox - Setting cursor
- PyQt5 QSpinBox - Accessing the cursor
- PyQt5 QSpinBox - How to unset the cursor
- PyQt5 QCalendarWidget - Changing Cursor Shape
- PyQt5 QCalendarWidget - Getting Cursor Shape
- PyQt5 QCalendarWidget - Making Cursor Shape back to normal
- wxPython - Change Cursor image on StaticText
- wxPython - Change Cursor on hover on Button
- wxPython - Change cursor for ToolBar
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.