diff --git a/README.md b/README.md index d79ea67..ab7492d 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,10 @@ skytable = "0.8" You're ready to go! ```rust -use skytable::{Query, Response, Config, query}; +use skytable::{ + Query, Response, Config, query, + response::Rows, +}; #[derive(Query, Response)] #[derive(Clone, PartialEq, Debug)] // we just do these for the assert (they are not needed) @@ -49,6 +52,10 @@ db.query_parse::<()>(&q).unwrap(); // select data let user: User = db.query_parse(&query!("select * from myspace.mymodel where username = ?", &our_user.userid)).unwrap(); assert_eq!(user, our_user); + +// select multiple rows +let users: Rows = db.query_parse(&query!("select all * from myspace.mymodel limit ?", 1000u64)).unwrap(); +assert_eq!(rows[0].userid, "user"); ``` > **Read [docs here to learn BlueQL](https://docs.skytable.io/)** diff --git a/src/response.rs b/src/response.rs index a6a6a25..1da5f85 100644 --- a/src/response.rs +++ b/src/response.rs @@ -359,6 +359,21 @@ impl FromRow for Row { #[derive(Debug, PartialEq)] /// A collection of rows +/// +/// ## Example +/// ```no_run +/// use skytable::{response::Rows, Config, Response, query}; +/// +/// #[derive(Response)] +/// struct User { +/// username: String, +/// password: String, +/// } +/// +/// let mut db = Config::new_default("user", "pass").connect().unwrap(); +/// let users: Rows = db.query_parse(&query!("select all * from myapp.users limit ?", 1000u64)).unwrap(); +/// assert_eq!(users[0].username, "sayan"); +/// ``` pub struct Rows(Vec); impl Rows {