The db.collection.find() method returns a cursor. To access
the documents, you need to iterate the cursor. However, in the
mongo shell, if the returned cursor is not assigned to a
variable using the var keyword, then the cursor is automatically
iterated up to 20 times [1] to print up to the
first 20 documents in the results.

The following examples describe ways to manually iterate the cursor to
access the documents or to use the iterator index.

The toArray() method loads into RAM all
documents returned by the cursor; the toArray()
method exhausts the cursor.

Additionally, some drivers provide
access to the documents by using an index on the cursor (i.e.
cursor[index]). This is a shortcut for first calling the
toArray() method and then using an index
on the resulting array.

By default, the server will automatically close the cursor after 10
minutes of inactivity, or if client has exhausted the cursor. To
override this behavior in the mongo shell, you can use
the cursor.noCursorTimeout() method:

As a cursor returns documents, other operations may interleave with the
query. For the MMAPv1 storage engine, intervening
write operations on a document may result in a cursor that returns a
document more than once if that document has changed. To handle this
situation, see the information on snapshot mode.

find() and aggregate() operations have an initial batch size
of 101 documents by default. Subsequent getMore
operations issued against the resulting cursor have no default batch
size, so they are limited only by the 16 megabyte message size.

For queries that include a sort operation without an index, the
server must load all the documents in memory to perform the sort
before returning any results.

As you iterate through the cursor and reach the end of the returned
batch, if there are more results, cursor.next() will perform
a getMoreoperation to retrieve the next batch.
To see how many documents remain in the batch as you iterate the
cursor, you can use the objsLeftInBatch() method, as
in the following example: