You are browsing documentation for a version that is no longer maintained.
With a typical MongoDB cursor, it stays open during iteration and fetches batches of documents as you iterate over the cursor. This isn't bad, but sometimes you want to fetch all of the data eagerly. For example when dealing with web applications, and you want to only show 50 documents from a collection you should fetch all the data in your controller first before going on to the view.
- The cursor stays open for a much shorter period of time.
- Data retrieval and hydration are consolidated operations.
- Doctrine has the ability to retry the cursor when exceptions during interaction with mongodb are encountered.
At this point all data is loaded from the database and cursors to MongoDB have been closed but hydration of the data in to objects has not begun. Once insertion starts the data will be hydrated in to PHP objects.
Not all documents are converted to objects at once, the hydration is still done one document at a time during iteration. The only change is that all data is retrieved first.