feat: add insert_many utility functions to catalog

This commit is contained in:
2025-09-29 13:27:51 +02:00
parent d752ed0140
commit 804e9b8536
2 changed files with 22 additions and 0 deletions

View File

@@ -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<impl ToEAV>) {
for object in objects {
let entity = object.to_eav();
self.items.insert(entity.id.clone(), entity);
}
}
}
// impl std::fmt::Display for O {

View File

@@ -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);
}
}