The documentation for the node -mongo-native collection.find() function says that it creates a cursor object that lazily returns the relevant documents, Also:
The main cursor operation is the nextObject method, which fetches the next matching document from the database. The convenience methods each and toArray call nextObject until the cursor is exhausted.
Unfortunately, the documentation does not indicate how to say when the cursor is actually exhausted. You can use the "toArray" method and use the standard array interface (for example, the "length" method), but this solution is not suitable for streaming large amounts of data. The MongoDB API refers to cursor.hasNext() in the mongo shell, but this method does not seem to be available in the node.js driver.
How can you determine when the cursor is exhausted while streaming data from MongoDB to node.js?
maerics
source share