Skip to content

DOCS-734 migrate natural order wiki #387

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 9, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions source/reference/glossary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -463,11 +463,17 @@ Glossary
management.

natural order
The order in which a database stores documents on disk.
Typically this order is the same as the
insertion order. :term:`Capped collections <capped collection>`,
among other things, guarantee that insertion order and natural
order are identical.
The order in which a database stores documents on disk. Typically
this order is the same as the insertion order, though it is not
guaranteed to be. :term:`Capped collections <capped collection>`
guarantee that insertion order and natural order are identical.

When you execute :method:`find() <db.collection.find()>` with no
parameters, the database returns documents in forward natural
order. When you execute :method:`find() <db.collection.find()>`
and include :method:`sort() <cursor.sort()>` with a parameter of
``$natural:-1``, the database returns documents in reverse natural
order.

primary key
A record's unique, immutable identifier. In an :term:`RDBMS`, the primary
Expand Down
10 changes: 10 additions & 0 deletions source/reference/method/cursor.sort.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,13 @@ cursor.sort()
than 32 megabytes, MongoDB will return an error. Use
:method:`cursor.limit()`, or create an index on the field that you're
sorting to avoid this error.

.. todo:: add an explanation of the $natural parameter:

The $natural parameter returns items according to their order
on disk. (link to glossary item on natural order)

For example, to return items in reverse order on disk, you
would invoke:

db.collection.find().sort({$natural:-1})