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