|
1 | 1 | ---
|
2 | 2 | title: Access system document properties
|
3 |
| -titleSuffix: Azure Cosmos DB for Graph |
4 |
| -description: Learn how to read and write Azure Cosmos DB system document properties via the API for Gremlin. |
| 3 | +titleSuffix: Azure Cosmos DB for Apache Gremlin |
| 4 | +description: Learn how to read and write system document properties using Azure Cosmos DB for Apache Gremlin. |
| 5 | +author: seesharprun |
| 6 | +ms.author: sidandrews |
| 7 | +ms.reviewer: mansha |
5 | 8 | ms.service: cosmos-db
|
6 | 9 | ms.subservice: apache-gremlin
|
7 | 10 | ms.topic: how-to
|
8 |
| -ms.date: 09/16/2021 |
9 |
| -author: manishmsfte |
10 |
| -ms.author: mansha |
| 11 | +ms.date: 02/08/2024 |
11 | 12 | ---
|
12 | 13 |
|
13 |
| -# System document properties |
| 14 | +# Access system document properties using Azure Cosmos DB for Apache Gremlin |
| 15 | + |
14 | 16 | [!INCLUDE[Gremlin](../includes/appliesto-gremlin.md)]
|
15 | 17 |
|
16 |
| -Azure Cosmos DB has [system properties](/rest/api/cosmos-db/databases) such as ```_ts```, ```_self```, ```_attachments```, ```_rid```, and ```_etag``` on every document. Additionally, Gremlin engine adds ```inVPartition``` and ```outVPartition``` properties on edges. By default, these properties are available for traversal. However, it's possible to include specific properties, or all of them, in Gremlin traversal. |
| 18 | +Azure Cosmos DB has [system properties](/rest/api/cosmos-db/databases) such as `_ts`, `_self`, `_attachments`, `_rid`, and `_etag` on every document. Additionally, Gremlin engine adds `inVPartition` and `outVPartition` properties on edges. By default, these properties are available for traversal. However, it's possible to include specific properties, or all of them, in Gremlin traversal. |
17 | 19 |
|
18 |
| -```console |
| 20 | +`console |
19 | 21 | g.withStrategies(ProjectionStrategy.build().IncludeSystemProperties('_ts').create())
|
20 |
| -``` |
| 22 | +` |
21 | 23 |
|
22 | 24 | ## E-Tag
|
23 | 25 |
|
24 | 26 | This property is used for optimistic concurrency control. If application needs to break operation into a few separate traversals, it can use eTag property to avoid data loss in concurrent writes.
|
25 | 27 |
|
26 |
| -```console |
| 28 | +`console |
27 | 29 | g.withStrategies(ProjectionStrategy.build().IncludeSystemProperties('_etag').create()).V('1').has('_etag', '"00000100-0000-0800-0000-5d03edac0000"').property('test', '1')
|
28 |
| -``` |
| 30 | +` |
29 | 31 |
|
30 | 32 | ## Time-to-live (TTL)
|
31 | 33 |
|
32 | 34 | If collection has document expiration enabled and documents have `ttl` property set on them, then this property is available in Gremlin traversal as a regular vertex or edge property. `ProjectionStrategy` isn't necessary to enable time-to-live property exposure.
|
33 | 35 |
|
34 | 36 | * Use the following command to set time-to-live on a new vertex:
|
35 | 37 |
|
36 |
| - ```console |
| 38 | + `console |
37 | 39 | g.addV(<ID>).property('ttl', <expirationTime>)
|
38 |
| - ``` |
| 40 | + ` |
39 | 41 |
|
40 | 42 | For example, a vertex created with the following traversal is automatically deleted after *123 seconds*:
|
41 | 43 |
|
42 |
| - ```console |
| 44 | + `console |
43 | 45 | g.addV('vertex-one').property('ttl', 123)
|
44 |
| - ``` |
| 46 | + ` |
45 | 47 |
|
46 | 48 | * Use the following command to set time-to-live on an existing vertex:
|
47 | 49 |
|
48 |
| - ```console |
| 50 | + `console |
49 | 51 | g.V().hasId(<ID>).has('pk', <pk>).property('ttl', <expirationTime>)
|
50 |
| - ``` |
| 52 | + ` |
51 | 53 |
|
52 | 54 | * Applying time-to-live property on vertices doesn't automatically apply it to edges. Because edges are independent records in the database store. Use the following command to set time-to-live on vertices and all the incoming and outgoing edges of the vertex:
|
53 | 55 |
|
54 |
| - ```console |
| 56 | + `console |
55 | 57 | g.V().hasId(<ID>).has('pk', <pk>).as('v').bothE().hasNot('ttl').property('ttl', <expirationTime>)
|
56 |
| - ``` |
| 58 | + ` |
57 | 59 |
|
58 | 60 | You can set time to Live (TTL) on the container to -1 or set it to **On (no default)** from Azure portal, then the TTL is infinite for any item unless the item has TTL value explicitly set.
|
59 | 61 |
|
|
0 commit comments