Skip to content

Commit 3199711

Browse files
authored
Merge pull request #95851 from sandeepsnairms/MongoTTLArticle
response was shown as part of command, removed response
2 parents ec6fb81 + 79873d3 commit 3199711

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

articles/cosmos-db/mongodb/mongodb-time-to-live.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: MongoDB per-document TTL feature in Azure Cosmos DB
3-
description: Learn how to set time to live value for documents using Azure Cosmos DB's API for MongoDB to automatically purge them from the system after a period of time.
3+
description: Learn how to set time to live value for documents using Azure Cosmos DB's API for MongoDB, to automatically purge them from the system after a period of time.
44
author: gahl-levy
55
ms.author: gahllevy
66
ms.service: cosmos-db
@@ -22,6 +22,12 @@ MongoShell example:
2222

2323
```
2424
globaldb:PRIMARY> db.coll.createIndex({"_ts":1}, {expireAfterSeconds: 10})
25+
```
26+
The command in the above example will create an index with TTL functionality.
27+
28+
The output of the command includes various metadata:
29+
30+
```output
2531
{
2632
"_t" : "CreateIndexesResponse",
2733
"ok" : 1,
@@ -31,7 +37,7 @@ globaldb:PRIMARY> db.coll.createIndex({"_ts":1}, {expireAfterSeconds: 10})
3137
}
3238
```
3339

34-
The command in the above example will create an index with TTL functionality. 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.
40+
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.
3541

3642
> [!NOTE]
3743
> `_ts` is a 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.

0 commit comments

Comments
 (0)