File tree Expand file tree Collapse file tree 2 files changed +25
-5
lines changed Expand file tree Collapse file tree 2 files changed +25
-5
lines changed Original file line number Diff line number Diff line change @@ -463,11 +463,19 @@ Glossary
463
463
management.
464
464
465
465
natural order
466
- The order in which a database stores documents on disk.
467
- Typically this order is the same as the
468
- insertion order. :term:`Capped collections <capped collection>`,
469
- among other things, guarantee that insertion order and natural
470
- order are identical.
466
+ The order in which a database stores documents on
467
+ disk. Typically, the order of documents on disks reflects
468
+ insertion order, *except* when documents move internal because
469
+ of document growth due to update operations. However,
470
+ :term:`Capped collections <capped collection>` guarantee that
471
+ insertion order and natural order are identical.
472
+
473
+ When you execute :method:`find() <db.collection.find()>` with no
474
+ parameters, the database returns documents in forward natural
475
+ order. When you execute :method:`find() <db.collection.find()>`
476
+ and include :method:`sort() <cursor.sort()>` with a parameter of
477
+ ``$natural:-1``, the database returns documents in reverse natural
478
+ order.
471
479
472
480
primary key
473
481
A record's unique, immutable identifier. In an :term:`RDBMS`, the primary
Original file line number Diff line number Diff line change @@ -47,3 +47,15 @@ cursor.sort()
47
47
than 32 megabytes, MongoDB will return an error. Use
48
48
:method:`cursor.limit()`, or create an index on the field that you're
49
49
sorting to avoid this error.
50
+
51
+ The :operator:`$natural` parameter returns items according to their
52
+ order on disk. Consider the following query:
53
+
54
+ .. code-block:: javascript
55
+
56
+ db.collection.find().sort( { $natural: -1 } )
57
+
58
+ This will return documents in the reverse of the order on
59
+ disk. Typically, the order of documents on disks reflects insertion
60
+ order, *except* when documents move internal because of document
61
+ growth due to update operations.
You can’t perform that action at this time.
0 commit comments