@@ -338,9 +338,6 @@ as in the following example:
338
338
339
339
db.bios.find( { _id: 1 } );
340
340
341
- This operation will iterate the cursor up to 20 times and print the
342
- first 20 documents referenced by the cursor.
343
-
344
341
If the result of the :method:`find() <db.collection.find()>` is
345
342
assigned to a variable:
346
343
@@ -459,29 +456,34 @@ its behavior, such as:
459
456
460
457
db.bios.find().skip( 5 )
461
458
462
- You may chain these cursor methods; however, the :method:`limit()
463
- <cursor.limit()>` method is always applied after the :method:`sort()
464
- <cursor.sort()>` even if you chain the methods in the reverse
465
- order [#dbquery-server]_:
459
+ You can chain these cursor methods, as in the following examples [#dbquery-server]_:
466
460
467
461
.. code-block:: javascript
468
462
463
+ db.bios.find().sort( { name: 1 } ).limit( 5 )
469
464
db.bios.find().limit( 5 ).sort( { name: 1 } )
470
465
471
466
See :ref:`JavaScript cursor methods <js-query-cursor-methods>` and your
472
467
:doc:`driver </applications/drivers>` documentation for more
473
468
information on cursor methods. See :ref:`read-operations-cursors` for
474
469
more information regarding cursors.
475
470
476
- .. [#dbquery-server] The server treats the query with the sort as a
477
- single object:
471
+ .. [#dbquery-server] Regardless of the order you chain the :method:`limit()
472
+ <cursor.limit()>` and the :method:`sort() <cursor.sort()>`, the
473
+ request to the server has the following structure that treats the
474
+ query and the :method:`sort() <cursor.sort()>` modifier as a single
475
+ object:
478
476
479
477
.. code-block:: javascript
480
478
481
479
db.bios.find( { $query: {}, $orderby: { name: 1 } } ).limit( 5 )
482
480
483
- For other cursor modifiers that are treated with the query as a
484
- single object, see the :doc:`meta query operators
481
+ This structure means that the :method:`limit() <cursor.limit()>`
482
+ method is always applied after the :method:`sort() <cursor.sort()>`
483
+ regardless of the order in which the client chains the two methods.
484
+
485
+ For other cursor modifiers that are sent with the
486
+ query as a single object to the server, see the :doc:`meta query operators
485
487
</reference/meta-query-operators>`.
486
488
487
489
.. _crud-read-findOne:
0 commit comments