updates the current version of a collection
(
lmdb: &MetaDb,
version: VersionNumber,
)
| 34 | |
| 35 | /// updates the current version of a collection |
| 36 | pub fn update_background_version( |
| 37 | lmdb: &MetaDb, |
| 38 | version: VersionNumber, |
| 39 | ) -> Result<(), WaCustomError> { |
| 40 | let env = lmdb.env.clone(); |
| 41 | let db = lmdb.db; |
| 42 | |
| 43 | let mut txn = env |
| 44 | .begin_rw_txn() |
| 45 | .map_err(|e| WaCustomError::DatabaseError(format!("Failed to begin transaction: {}", e)))?; |
| 46 | |
| 47 | let key = key!(m:background_version); |
| 48 | let bytes = version.to_le_bytes(); |
| 49 | |
| 50 | txn.put(db, &key, &bytes, WriteFlags::empty()) |
| 51 | .map_err(|e| WaCustomError::DatabaseError(format!("Failed to put data: {}", e)))?; |
| 52 | |
| 53 | txn.commit().map_err(|e| { |
| 54 | WaCustomError::DatabaseError(format!("Failed to commit transaction: {}", e)) |
| 55 | })?; |
| 56 | |
| 57 | Ok(()) |
| 58 | } |
| 59 | |
| 60 | pub fn store_values_range(lmdb: &MetaDb, range: (f32, f32)) -> lmdb::Result<()> { |
| 61 | let env = lmdb.env.clone(); |
no test coverage detected