From 187f89de56db8fd80e737598244bdc295cb6d137 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20Bary=C5=82a?= Date: Mon, 21 Oct 2024 18:26:16 +0200 Subject: [PATCH] docs: Add Counter UPDATE example Counter was the only data type that didn't have at least two examples: one for reading and one for writing. This commit adds the missing example. --- docs/source/data-types/counter.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/source/data-types/counter.md b/docs/source/data-types/counter.md index 0a11f0f62d..8e4bb1410d 100644 --- a/docs/source/data-types/counter.md +++ b/docs/source/data-types/counter.md @@ -11,6 +11,12 @@ use futures::TryStreamExt; use scylla::frame::value::Counter; +// Add to counter value +let to_add: Counter = Counter(100); +session + .query_unpaged("UPDATE keyspace.table SET c = c + ? WHERE pk = 15", (to_add,)) + .await?; + // Read counter from the table let mut iter = session.query_iter("SELECT c FROM keyspace.table", &[]) .await?