use eyre::Result;
use okv::backend::rocksdb::RocksDbOptimistic;
use okv::Env;
fn main() -> Result<()> {
std::fs::create_dir_all("database/example-transactions")?;
let rocksdb = RocksDbOptimistic::new("database/example-transactions")?;
let env = Env::new(rocksdb);
let db = env.open::<&str, &str>("test")?;
let tx = db.transaction()?;
tx.set_nx("hello", "world")?;
tx.commit()?;
let tx = db.transaction()?;
tx.set("hello", "sailor")?;
tx.rollback()?;
assert_eq!(db.get("hello")?, Some("world".to_string()));
Ok(())
}
#[test] fn test() -> Result<()> {
main()
}