Skip to content

Commit

Permalink
docs: added docs for vector type
Browse files Browse the repository at this point in the history
  • Loading branch information
smoczy123 committed Jan 13, 2025
1 parent 25802de commit 6aee097
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions docs/source/data-types/vector.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## Vector (for Cassandra only!)
`Vector` is represented as `Vec<T>`

```rust
# extern crate scylla;
# extern crate futures;
# use scylla::Session;
# use std::error::Error;
# async fn check_only_compiles(session: &Session) -> Result<(), Box<dyn Error>> {
use futures::TryStreamExt;

// Insert a vector of ints into the table
let my_vector: Vec<i32> = vec![1, 2, 3, 4, 5];
session
.query_unpaged("INSERT INTO keyspace.table (a) VALUES(?)", (&my_vector,))
.await?;

// Read a list of ints from the table
let mut stream = session.query_iter("SELECT a FROM keyspace.table", &[])
.await?
.rows_stream::<(Vec<i32>,)>()?;
while let Some((vector_value,)) = stream.try_next().await? {
println!("{:?}", vector);
}
# Ok(())
# }

0 comments on commit 6aee097

Please sign in to comment.