Crates.io | ood_persistence |
lib.rs | ood_persistence |
version | 0.3.1 |
source | src |
created_at | 2021-10-12 15:15:21.19667 |
updated_at | 2021-10-21 22:17:00.640064 |
description | Asynchronous and synchronous interfaces and persistence implementations for your OOD architecture |
homepage | |
repository | https://github.com/pleshevskiy/ood_persistence |
max_upload_size | |
id | 464011 |
size | 76,566 |
Asynchronous and synchronous interfaces and persistence implementations for your OOD architecture
Add ood_persistence = { version = "0", features = ["<IMPLEMENTATION_NAME>"] }
as a dependency in Cargo.toml
.
NOTE: change <IMPLEMENTATION_NAME>
to feature name from available list. See Cargo.toml
for more information.
Cargo.toml
example:
[package]
name = "my-crate"
version = "0.1.0"
authors = ["Me <user@rust-lang.org>"]
[dependencies]
ood_persistence = { version = "0", features = ["bb8_postgres"] }
In stable rust channel you can use only connection interface, but if you use nightly channel, add an additional
"nightly" feature to your Cargo.toml
and you can use transactions as well.
fn main() -> Result<(), Box<dyn std::error::Error>> {
// 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.
pleshevskiy (Dmitriy Pleshevskiy) – creator, maintainer.