From b15b1f23fd867a73da74f9036614424a0bd3a148 Mon Sep 17 00:00:00 2001 From: Joey Hines Date: Sat, 3 Feb 2024 11:11:11 -0700 Subject: [PATCH] Clear out DB before importing --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/database.rs | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b195356..03f9982 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -102,7 +102,7 @@ checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440" [[package]] name = "j_db" -version = "0.1.0" +version = "0.1.1" dependencies = [ "byteorder", "json", diff --git a/Cargo.toml b/Cargo.toml index e6a7c24..9e747cc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "j_db" -version = "0.1.0" +version = "0.1.1" authors = ["Joey Hines "] edition = "2021" description = "A good enough (TM) embedded Rust DB* and ORM*" diff --git a/src/database.rs b/src/database.rs index 775e181..a5d68a1 100644 --- a/src/database.rs +++ b/src/database.rs @@ -217,6 +217,7 @@ impl Database { } pub fn import_db(&self, json: JsonValue) -> Result<()> { + self.db.clear()?; for model in json["global"].members() { let id_bytes = model["id"].as_u64().unwrap().to_be_bytes(); self.db.insert(id_bytes, model.to_string().as_bytes())?;