I need this for create db if not exist
52
53 impl<'a> ReadTx<'a> {
54 pub fn ptr(&self) -> *const TxnEnv<'a> {
55 &self.0
56 }
57 pub fn btree<K: Storable, V: Storable>(&self, id: usize) -> btree::Db<K, V> {
58 let tx = &self.0;
59 match tx.root_db::<K, V, Page<K, V>>(id) {
60 None => {
61 let mut w = Env::mut_txn_begin(tx.env_borrow()).unwrap();
62 let tree = btree::create_db::<_, K, V>(&mut w).unwrap();
63 w.set_root(id, tree.db);
64 w.commit().unwrap();
65 tree
66 }
67 Some(tree) => tree,
68 }
69 }
70 }
Thanks! I’ve just applied it to main, and published it to crates.io.