Skip to content

Commit

Permalink
docs: adding context to timeuuid using v1 feature
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielHe4rt committed May 12, 2024
1 parent 64d3c71 commit 599a2be
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions docs/source/data-types/timeuuid.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

The `Timeuuid` type is represented as `value::CqlTimeuuid`.

Also, `value::CqlTimeuuid` is a wrapper for `uuid::Uuid` with custom ordering logic which follows Scylla/Cassandra semantics.
Also, `value::CqlTimeuuid` is a wrapper for `uuid::Uuid` with custom ordering logic which follows Scylla/Cassandra semantics.

```rust
# extern crate scylla;
Expand All @@ -15,15 +15,18 @@ use scylla::frame::value::CqlTimeuuid;

// Insert some timeuuid into the table
let to_insert: CqlTimeuuid = CqlTimeuuid::from_str("8e14e760-7fa8-11eb-bc66-000000000001")?;

session
.query("INSERT INTO keyspace.table (a) VALUES(?)", (to_insert,))
.await?;

// Read timeuuid from the table
if let Some(rows) = session.query("SELECT a FROM keyspace.table", &[]).await?.rows {
for row in rows.into_typed::<(CqlTimeuuid,)>() {
let (timeuuid_value,): (CqlTimeuuid,) = row?;
}
// Read Timeuuid from the table
let result = session.query("SELECT a FROM keyspace.table", &[]).await?;

let mut iter = result.rows_typed::<(CqlTimeuuid, )>()?;

while let Some((timeuuid,)) = iter.next().transpose()? {
println!("Read a value from row: {}", timeuuid);
}
# Ok(())
# }
Expand Down Expand Up @@ -60,11 +63,13 @@ session
.query("INSERT INTO keyspace.table (a) VALUES(?)", (to_insert,))
.await?;

// Read timeuuid from the table
if let Some(rows) = session.query("SELECT a FROM keyspace.table", &[]).await?.rows {
for row in rows.into_typed::<(CqlTimeuuid,)>() {
let (timeuuid_value,): (CqlTimeuuid,) = row?;
}
// Read Timeuuid from the table
let result = session.query("SELECT a FROM keyspace.table", &[]).await?;

let mut iter = result.rows_typed::<(CqlTimeuuid, )>()?;

while let Some((timeuuid,)) = iter.next().transpose()? {
println!("Read a value from row: {}", timeuuid);
}
# Ok(())
# }
Expand Down

0 comments on commit 599a2be

Please sign in to comment.