@@ -18,6 +18,11 @@ store data in MongoDB and have the :binary:`~bin.mongod` automatically
18
18
remove data after a specified number of seconds or at a specific clock
19
19
time.
20
20
21
+ You can expire data for deployments hosted in the following
22
+ environments:
23
+
24
+ .. include:: /includes/fact-environments.rst
25
+
21
26
Data expiration is useful for some classes of information, including
22
27
machine generated event data, logs, and session information that only
23
28
need to persist for a limited period of time.
@@ -39,9 +44,83 @@ collection.
39
44
You can modify the ``expireAfterSeconds`` of an existing TTL index
40
45
using the :dbcommand:`collMod` command.
41
46
47
+ Expire Documents in the {+atlas+} UI
48
+ -------------------------------------------------------
49
+
50
+ To expire data in the :ref:`Atlas UI <atlas-ui-overview>`, follow
51
+ these steps:
52
+
53
+ .. procedure::
54
+ :style: normal
55
+
56
+ .. step:: Navigate to the collection
57
+
58
+ a. In the {+atlas+} UI, click :guilabel:`Database` in the sidebar.
59
+ #. For the database deployment that contains the data you want to
60
+ expire, click :guilabel:`Browse Collections`.
61
+ #. In the left navigation pane, select the database.
62
+ #. In the left navigation pane, select the collection.
63
+
64
+ .. step:: Open the :guilabel:`Create Index` modal
65
+
66
+ a. Click the :guilabel:`Indexes` tab.
67
+ #. Click :guilabel:`Create Index`.
68
+
69
+ .. step:: Create the index with the ``expiresAfterSeconds`` option
70
+
71
+ a. In the :guilabel:`Fields` section, enter the index key
72
+ specification document. For this example, enter the
73
+ following text to create an index on the
74
+ ``expiresAfter`` field:
75
+
76
+ .. code-block::
77
+
78
+ { "expiresAfter": 1 }
79
+
80
+ b. In the :guilabel:`Options` section, enter the
81
+ ``expireAfterSeconds`` option. For this example, enter the
82
+ following text to expire the data 1 second after the
83
+ ``expiresAfter`` field's value:
84
+
85
+ .. code-block::
86
+
87
+ { expireAfterSeconds: 1 }
88
+
89
+ #. Click :guilabel:`Review`.
90
+ #. Click :guilabel:`Confirm`.
91
+
92
+ .. step:: Add a document that contains the ``expiresAfter`` field to the collection
93
+
94
+ a. In the left navigation pane, select the collection that
95
+ contains the index.
96
+ #. Click the :guilabel:`Find` tab.
97
+ #. Click :guilabel:`Insert Document`.
98
+ #. Click the text field under the :guilabel:`_id` field and enter
99
+ the field name ``expiresAfter``.
100
+ #. Click the text field next to ``expiresAfter`` and enter the
101
+ following value:
102
+
103
+ .. code-block::
104
+
105
+ 2023-10-01T12:00:00.000+00:00
106
+
107
+ This value expires data after 12:00 on October
108
+ 1, 2023.
109
+ #. Click the data type drop-down menu and change the data type
110
+ value to :guilabel:`Date`.
111
+ #. Click :guilabel:`Insert`.
112
+
113
+ The document will expire automatically one second after the
114
+ ``expiredAfter`` field's value.
115
+
116
+ The TTL index may take 1-2 seconds to expire the document.
117
+ You may need to refresh the UI to see that {+atlas+} deletes
118
+ the expired document.
119
+
42
120
Expire Documents after a Specified Number of Seconds
43
121
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
44
122
123
+ You can expire data after a specified number of seconds in the terminal.
45
124
To expire data after a specified number of seconds has passed since the
46
125
indexed field, create a TTL index on a field that holds values of BSON
47
126
date type or an array of BSON date-typed objects *and* specify a
@@ -83,7 +162,8 @@ specified in ``expireAfterSeconds``.
83
162
Expire Documents at a Specific Clock Time
84
163
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
85
164
86
- To expire documents at a specific clock time, begin by creating a TTL
165
+ You can expire data at a specified clock time in the terminal. To
166
+ expire documents at a specific clock time, begin by creating a TTL
87
167
index on a field that holds values of BSON date type or an array of
88
168
BSON date-typed objects *and* specify an ``expireAfterSeconds`` value
89
169
of ``0``. For each document in the collection, set the indexed date
0 commit comments