From 804e9b8536c1063b3e61fd1d90d3690ac86b8d9a Mon Sep 17 00:00:00 2001 From: davidemazzocchi Date: Mon, 29 Sep 2025 13:27:51 +0200 Subject: [PATCH] feat: add insert_many utility functions to catalog --- 01.workspace/heave/src/str/catalog.rs | 6 ++++++ 01.workspace/heave/src/tst/intended_use.rs | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/01.workspace/heave/src/str/catalog.rs b/01.workspace/heave/src/str/catalog.rs index 753a87a..d1a6f02 100644 --- a/01.workspace/heave/src/str/catalog.rs +++ b/01.workspace/heave/src/str/catalog.rs @@ -17,6 +17,12 @@ impl O { let entity = object.to_eav(); self.items.insert(entity.id.clone(), entity); } + pub fn insert_many(&mut self, objects: Vec) { + for object in objects { + let entity = object.to_eav(); + self.items.insert(entity.id.clone(), entity); + } + } } // impl std::fmt::Display for O { diff --git a/01.workspace/heave/src/tst/intended_use.rs b/01.workspace/heave/src/tst/intended_use.rs index 86cbbde..74f82c2 100644 --- a/01.workspace/heave/src/tst/intended_use.rs +++ b/01.workspace/heave/src/tst/intended_use.rs @@ -132,4 +132,20 @@ mod tests { }; catalog.insert(product); } + #[test] + fn check_008() { + let mut catalog = Catalog::new(""); + let product01 = Product { + id: short_uuid::short!().to_string(), + name: "laptop".to_string(), + price: 200000u64, + }; + let product02 = Product { + id: short_uuid::short!().to_string(), + name: "desktop".to_string(), + price: 150000u64, + }; + let products = vec![product01, product02]; + catalog.insert_many(products); + } }