diff --git a/README.md b/README.md index 275c010..065af28 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,23 @@ In stable rust channel you can use only connection interface, but if you use nig ## Usage -See examples directory. +```rust +fn main() -> Result<(), Box> { + // create pool to our database + let pool = create_postgres_pool(); + // initialize persistence + let persistence = ood_persistence::r2d2_postgres::new(&pool); + // get connection to database + let mut conn = persistence.get_connection()?; + // we can query something + let res: i32 = conn.inner().query_one("select 1", &[])?.get(0); + assert_eq!(res, 1); + + Ok(()) +} +``` + +See examples directory for more information. ## Contributors diff --git a/src/lib.rs b/src/lib.rs index 9f1ea48..9468b36 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -25,7 +25,27 @@ //! //! ## Usage //! -//! See examples directory. +//! ```rust +//! fn main() -> Result<(), Box> { +//! // create pool to our database +//! let pool = create_postgres_pool(); +//! // initialize persistence +//! let persistence = ood_persistence::r2d2_postgres::new(&pool); +//! // get connection to database +//! let mut conn = persistence.get_connection()?; +//! // we can query something +//! let res: i32 = conn.inner().query_one("select 1", &[])?.get(0); +//! assert_eq!(res, 1); +//! +//! Ok(()) +//! } +//! ``` +//! +//! See examples directory for more information. +//! +//! ## Contributors +//! +//! [pleshevskiy](https://github.com/pleshevskiy) (Dmitriy Pleshevskiy) – creator, maintainer. //! #![forbid(unsafe_code, non_ascii_idents)] #![deny(clippy::pedantic)]