-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(()) | ||
# } |