Skip to content

Commit

Permalink
docs: Add Counter UPDATE example
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Lorak-mmk committed Oct 21, 2024
1 parent 1ec6020 commit 187f89d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/source/data-types/counter.md
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down

0 comments on commit 187f89d

Please sign in to comment.