You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/cosmos-db/mongodb/time-to-live.md
+10-9Lines changed: 10 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ ms.subservice: mongodb
8
8
ms.devlang: csharp
9
9
# ms.devlang: csharp, java, javascript
10
10
ms.topic: how-to
11
-
ms.date: 02/16/2022
11
+
ms.date: 06/05/2024
12
12
ms.custom: devx-track-csharp
13
13
---
14
14
# Expire data with Azure Cosmos DB's API for MongoDB
@@ -38,7 +38,7 @@ The output of the command includes various metadata:
38
38
}
39
39
```
40
40
41
-
Once the index is created, the database will automatically delete any documents in that collection that have not been modified in the last 10 seconds.
41
+
Once the index is created, the database will automatically delete any documents in that collection that haven't been modified in the last 10 seconds.
42
42
43
43
> [!NOTE]
44
44
> `_ts` is an Azure Cosmos DB-specific field and is not accessible from MongoDB clients. It is a reserved (system) property that contains the timestamp of the document's last modification.
Per-document TTL values are also supported. The document(s) must contain a root-level property "ttl" (lower-case), and a TTL index as described above must have been created for that collection. TTL values set on a document will override the collection's TTL value.
64
+
Per-document TTL values are also supported. The document(s) must contain a root-level property "ttl" (lower-case), and a TTL index as described above must have been created for that collection. TTL values set on a document overrides the collection's TTL value.
65
65
66
-
The TTL value must be an int32. Alternatively, an int64 that fits in an int32, or a double with no decimal part that fits in an int32. Values for the TTL property that do not conform to these specifications are allowed but not treated as a meaningful document TTL value.
66
+
The TTL value must be an int32. Alternatively, an int64 that fits in an int32, or a double with no decimal part that fits in an int32. Values for the TTL property that don't conform to these specifications are allowed but not treated as a meaningful document TTL value.
67
67
68
-
The TTL value for the document is optional; documents without a TTL value can be inserted into the collection. In this case, the collection's TTL value will be honored.
68
+
The TTL value for the document is optional; documents without a TTL value can be inserted into the collection. In this case, the collection's TTL value is honored.
69
69
70
70
The following documents have valid TTL values. Once the documents are inserted, the document TTL values override the collection's TTL values. So, the documents will be removed after 20 seconds.
The following documents have invalid TTL values. The documents will be inserted, but the document TTL value will not be honored. So, the documents will be removed after 10 seconds because of the collection's TTL value.
78
+
The following documents have invalid TTL values. The documents are inserted, but the document TTL value won't be honored. So, the documents will be removed after 10 seconds because of the collection's TTL value.
79
79
80
80
```JavaScript
81
81
globaldb:PRIMARY>db.coll.insert({id:1, location:"Paris", ttl:20.5}) //TTL value contains non-zero decimal part.
82
82
globaldb:PRIMARY>db.coll.insert({id:1, location:"Paris", ttl:NumberLong(2147483649)}) //TTL value is greater than Int32.MaxValue (2,147,483,648).
83
83
```
84
84
85
-
## Next steps
86
-
*[Expire data in Azure Cosmos DB automatically with time to live](../mongodb/time-to-live.md)
87
-
*[Indexing your Azure Cosmos DB database configured with Azure Cosmos DB's API for MongoDB](../mongodb/indexing.md)
85
+
## Next step
86
+
87
+
> [!div class="nextstepaction"]
88
+
> [Indexing your Azure Cosmos DB database configured with Azure Cosmos DB's API for MongoDB](../mongodb/indexing.md)
0 commit comments