diff options
| author | asmyasnikov <[email protected]> | 2022-12-08 16:54:41 +0300 |
|---|---|---|
| committer | asmyasnikov <[email protected]> | 2022-12-08 16:54:41 +0300 |
| commit | f82e9035da59f4625a16b5c3c03a9818f5be1398 (patch) | |
| tree | 98dc910be8347125a71581f9504861ad6638ac09 | |
| parent | 184139dabad7cef9d825457c36d3725c153fba62 (diff) | |
Add TTL tabs for Go
Add TTL tabs for Go
| -rw-r--r-- | ydb/docs/en/core/concepts/_includes/ttl.md | 52 | ||||
| -rw-r--r-- | ydb/docs/ru/core/concepts/_includes/ttl.md | 52 |
2 files changed, 102 insertions, 2 deletions
diff --git a/ydb/docs/en/core/concepts/_includes/ttl.md b/ydb/docs/en/core/concepts/_includes/ttl.md index 96532267146..6c12dbb46dd 100644 --- a/ydb/docs/en/core/concepts/_includes/ttl.md +++ b/ydb/docs/en/core/concepts/_includes/ttl.md @@ -63,7 +63,7 @@ Currently, you can manage TTL settings using: * [YQL](../../yql/reference/index.md). * [{{ ydb-short-name }} console client](../../reference/ydb-cli/index.md). -* {{ ydb-short-name }} {% if oss %}C++ and{% endif %} Python [SDK](../../reference/ydb-sdk/index.md). +* {{ ydb-short-name }} {% if oss %}C++, {% endif %}Go and Python [SDK](../../reference/ydb-sdk/index.md). ### Enabling TTL for an existing table {#enable-on-existent-table} @@ -99,6 +99,16 @@ In the example below, the items of the `mytable` table will be deleted an hour a {% endif %} +- Go + + ```go + err := session.AlterTable(ctx, "mytable", + options.WithSetTimeToLiveSettings( + options.NewTTLSettings().ColumnDateType("created_at").ExpireAfter(time.Hour), + ), + ) + ``` + - Python ```python @@ -139,6 +149,16 @@ The example below shows how to use the `modified_at` column with a numeric type {% endif %} +- Go + + ```go + err := session.AlterTable(ctx, "mytable", + options.WithSetTimeToLiveSettings( + options.NewTTLSettings().ColumnSecond("modified_at").ExpireAfter(time.Hour), + ), + ) + ``` + - Python ```python @@ -183,6 +203,18 @@ For a newly created table, you can pass TTL settings along with the table descri {% endif %} +- Go + + ```go + err := session.CreateTable(ctx, "mytable", + options.WithColumn("id", types.Optional(types.TypeUint64)), + options.WithColumn("expire_at", types.Optional(types.TypeTimestamp)), + options.WithTimeToLiveSettings( + options.NewTTLSettings().ColumnSecond("modified_at").ExpireAfter(time.Hour), + ), + ) + ``` + - Python ```python @@ -230,6 +262,14 @@ For a newly created table, you can pass TTL settings along with the table descri {% endif %} +- Go + + ```go + err := session.AlterTable(ctx, "mytable", + options.WithDropTimeToLive(), + ) + ``` + - Python ```python @@ -261,6 +301,16 @@ The current TTL settings can be obtained from the table description: {% endif %} +- Go + + ```go + desc, err := session.DescribeTable(ctx, "mytable") + if err != nil { + // process error + } + ttl := desc.TimeToLiveSettings + ``` + - Python ```python diff --git a/ydb/docs/ru/core/concepts/_includes/ttl.md b/ydb/docs/ru/core/concepts/_includes/ttl.md index 54c3b4218d8..cadd5720b43 100644 --- a/ydb/docs/ru/core/concepts/_includes/ttl.md +++ b/ydb/docs/ru/core/concepts/_includes/ttl.md @@ -63,7 +63,7 @@ expiration_time = valueof(ttl_column) + expire_after_seconds * [YQL](../../yql/reference/index.md). * [Консольного клиента {{ ydb-short-name }}](../../reference/ydb-cli/index.md). -* {{ ydb-short-name }} {% if oss %}C++ и{% endif %} Python [SDK](../../reference/ydb-sdk/index.md). +* {{ ydb-short-name }} {% if oss %}C++, {% endif %}Go и Python [SDK](../../reference/ydb-sdk/index.md). ### Включение TTL для существующей таблицы {#enable-on-existent-table} @@ -99,6 +99,16 @@ expiration_time = valueof(ttl_column) + expire_after_seconds {% endif %} +- Go + + ```go + err := session.AlterTable(ctx, "mytable", + options.WithSetTimeToLiveSettings( + options.NewTTLSettings().ColumnDateType("created_at").ExpireAfter(time.Hour), + ), + ) + ``` + - Python ```python @@ -139,6 +149,16 @@ expiration_time = valueof(ttl_column) + expire_after_seconds {% endif %} +- Go + + ```go + err := session.AlterTable(ctx, "mytable", + options.WithSetTimeToLiveSettings( + options.NewTTLSettings().ColumnSecond("modified_at").ExpireAfter(time.Hour), + ), + ) + ``` + - Python ```python @@ -183,6 +203,18 @@ expiration_time = valueof(ttl_column) + expire_after_seconds {% endif %} +- Go + + ```go + err := session.CreateTable(ctx, "mytable", + options.WithColumn("id", types.Optional(types.TypeUint64)), + options.WithColumn("expire_at", types.Optional(types.TypeTimestamp)), + options.WithTimeToLiveSettings( + options.NewTTLSettings().ColumnSecond("modified_at").ExpireAfter(time.Hour), + ), + ) + ``` + - Python ```python @@ -230,6 +262,14 @@ expiration_time = valueof(ttl_column) + expire_after_seconds {% endif %} +- Go + + ```go + err := session.AlterTable(ctx, "mytable", + options.WithDropTimeToLive(), + ) + ``` + - Python ```python @@ -261,6 +301,16 @@ expiration_time = valueof(ttl_column) + expire_after_seconds {% endif %} +- Go + + ```go + desc, err := session.DescribeTable(ctx, "mytable") + if err != nil { + // process error + } + ttl := desc.TimeToLiveSettings + ``` + - Python ```python |
