Skip to content

DOCSP-14170 clarify TTL index requirements #4843

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
Jan 27, 2021
Merged
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
13 changes: 7 additions & 6 deletions source/core/index-ttl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@ of time or at a specific clock time. Data expiration is useful for certain types
like machine generated event data, logs, and session information that
only need to persist in a database for a finite amount of time.

To create a TTL index, use the :method:`db.collection.createIndex()`
method with the ``expireAfterSeconds`` option on a field whose value is
either a :ref:`date <document-bson-type-date>` or an array that
contains :ref:`date values <document-bson-type-date>`.
To create a TTL index, use the :method:`~db.collection.createIndex()`
method on a field whose value is either a :ref:`date
<document-bson-type-date>` or an array that contains :ref:`date values
<document-bson-type-date>`, and specify the ``expireAfterSeconds``
option with the desired TTL value in seconds.

For example, to create a TTL index on the ``lastModifiedDate`` field of
the ``eventlog`` collection, use the following operation in the
:binary:`~bin.mongo` shell:
the ``eventlog`` collection, with a TTL value of ``3600`` seconds, use
the following operation in the :binary:`~bin.mongo` shell:

.. code-block:: javascript

Expand Down