5 个不稳定版本
| 0.3.1 | 2021 年 10 月 21 日 |
|---|---|
| 0.3.0 |
|
| 0.2.1 | 2021 年 10 月 17 日 |
| 0.1.1 | 2021 年 10 月 12 日 |
#16 in #implementation
29KB
426 行
OOD Persistence
为您的 OOD 架构提供异步和同步接口以及持久化实现
安装
将 ood_persistence = { version = "", features = [<IMPLEMENTATION_NAME>] } 添加为 Cargo.toml 的依赖项。
注意:将 <IMPLEMENTATION_NAME> 替换为可用列表中的功能名称。有关更多信息,请参阅 Cargo.toml。
Cargo.toml 示例
[package]
name = "my-crate"
version = "0.1.0"
authors = ["Me <user@rust-lang.org>"]
[dependencies]
ood_persistence = { version = "0", features = ["bb8_postgres"] }
在稳定 rust 通道中,您只能使用连接接口,但如果您使用夜间通道,请将“nightly”功能添加到您的 Cargo.toml 中,您还可以使用事务。
用法
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(())
}
有关更多信息,请参阅示例目录。
贡献者
pleshevskiy (Dmitriy Pleshevskiy) – 创建者,维护者。
依赖关系
~0–16MB
~216K SLoC