Skip to content

Commit 187f89d

Browse files
committed
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.
1 parent 1ec6020 commit 187f89d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

docs/source/data-types/counter.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111
use futures::TryStreamExt;
1212
use scylla::frame::value::Counter;
1313

14+
// Add to counter value
15+
let to_add: Counter = Counter(100);
16+
session
17+
.query_unpaged("UPDATE keyspace.table SET c = c + ? WHERE pk = 15", (to_add,))
18+
.await?;
19+
1420
// Read counter from the table
1521
let mut iter = session.query_iter("SELECT c FROM keyspace.table", &[])
1622
.await?

0 commit comments

Comments
 (0)