|
16 | 16 |
|
17 | 17 | //! # Skytable driver
|
18 | 18 | //! [](https://crates.io/crates/skytable) [](https://github.com/skytable/client-rust/actions/workflows/test.yml) [](https://docs.rs/skytable) [](https://github.com/skytable/client-rust/releases)
|
19 |
| -//! |
| 19 | +//! |
20 | 20 | //! This is [Skytable](https://github.com/skytable/skytable)'s official client driver for Rust that you can use to build applications.
|
21 | 21 | //! The client-driver is distributed under the liberal [Apache-2.0 License](https://www.apache.org/licenses/LICENSE-2.0) and hence
|
22 | 22 | //! you can use it in your applications without any licensing issues.
|
23 |
| -//! |
| 23 | +//! |
24 | 24 | //! ## Getting started
|
25 |
| -//! |
| 25 | +//! |
26 | 26 | //! Make sure you have Skytable set up. If not, follow the [official installation guide here](https://docs.skytable.io/installation)
|
27 | 27 | //! and then come back here.
|
28 |
| -//! |
| 28 | +//! |
29 | 29 | //! Let's run our first query. Connections are set up using the [`Config`] object and then we establish a connection by calling
|
30 | 30 | //! [`Config::connect`] or use other functions for different connection configurations (for TLS or async).
|
31 |
| -//! |
| 31 | +//! |
32 | 32 | //! ```no_run
|
33 | 33 | //! use skytable::{Config, query};
|
34 | 34 | //! let mut db = Config::new_default("username", "password").connect().unwrap();
|
35 | 35 | //! // the query `sysctl report status` returns a `Response::Empty` indicating that everything is okay. This is equivalent to
|
36 | 36 | //! // rust's unit type `()` so that's what the driver uses
|
37 | 37 | //! db.query_parse::<()>(&query!("sysctl report status")).unwrap();
|
38 | 38 | //! ```
|
39 |
| -//! |
| 39 | +//! |
40 | 40 | //! We used the [`query!`] macro above which allows us to conveniently create queries when we don't need to handle complex
|
41 | 41 | //! cases and we have a fixed number of arguments.
|
42 |
| -//! |
| 42 | +//! |
43 | 43 | //! ## Diving in
|
44 |
| -//! |
| 44 | +//! |
45 | 45 | //! Now let's say that we have a model `create model myspace.mymodel(username: string, password: string, followers: uint64)`
|
46 | 46 | //! and we want to do some DML operations. Here's how we do it.
|
47 |
| -//! |
| 47 | +//! |
48 | 48 | //! ```no_run
|
49 | 49 | //! use skytable::{Config, query};
|
50 | 50 | //! let mut db = Config::new_default("username", "password").connect().unwrap();
|
51 |
| -//! |
| 51 | +//! |
52 | 52 | //! let insert_query = query!("insert into myspace.mymodel(?, ?, ?)", "sayan", "pass123", 1_500_000_u64);
|
53 | 53 | //! db.query_parse::<()>(&insert_query).unwrap(); // insert will return empty on success
|
54 |
| -//! |
| 54 | +//! |
55 | 55 | //! let select_query = query!("select password, followers FROM myspace.mymodel WHERE username = ?", "sayan");
|
56 | 56 | //! let (pass, followers): (String, u64) = db.query_parse(&select_query).unwrap();
|
57 | 57 | //! assert_eq!(pass, "pass123");
|
58 | 58 | //! assert_eq!(followers, 1_500_000_u64);
|
59 |
| -//! |
| 59 | +//! |
60 | 60 | //! let update_query = query!("update myspace.mymodel set followers += ? where username = ?", 1u64, "sayan");
|
61 | 61 | //! db.query_parse::<()>(&update_query).unwrap(); // update will return empty on success
|
62 | 62 | //! ```
|
63 |
| -//! |
| 63 | +//! |
64 | 64 | //! Now you're ready to run your own queries!
|
65 |
| -//! |
| 65 | +//! |
66 | 66 | //! ## Going advanced
|
67 |
| -//! |
| 67 | +//! |
68 | 68 | //! - Custom [`mod@query`] generation
|
69 | 69 | //! - Custom [`response`] parsing
|
70 | 70 | //! - [`Connection pooling`](pool)
|
71 |
| -//! |
| 71 | +//! |
72 | 72 | //! ## Need help? Get help!
|
73 |
| -//! |
| 73 | +//! |
74 | 74 | //! Jump into [Skytable's official Discord server](https://discord.com/invite/QptWFdx) where maintainers, developers and fellow
|
75 | 75 | //! users help each other out.
|
76 |
| -//! |
| 76 | +//! |
77 | 77 |
|
78 | 78 | // internal modules
|
79 | 79 | #[macro_use]
|
|
0 commit comments