Skip to content

Commit 2149bc5

Browse files
author
Sam Kleinman
committed
merge: DOCS-734
2 parents b29fe79 + 84aa173 commit 2149bc5

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

source/reference/glossary.txt

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -463,11 +463,19 @@ Glossary
463463
management.
464464

465465
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.
471479

472480
primary key
473481
A record's unique, immutable identifier. In an :term:`RDBMS`, the primary

source/reference/method/cursor.sort.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,15 @@ cursor.sort()
4747
than 32 megabytes, MongoDB will return an error. Use
4848
:method:`cursor.limit()`, or create an index on the field that you're
4949
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.

0 commit comments

Comments
 (0)