Start to implement the save_all method.

This commit is contained in:
Florian THIERRY
2026-07-17 15:01:47 +02:00
parent ad44b181cb
commit 437314f304
4 changed files with 46 additions and 16 deletions
@@ -61,4 +61,31 @@ impl LibraryItemSqliteRepository {
}
)
}
fn save_all(&self, entities: Vec<LibraryItemEntity>) -> Result<(), Error> {
let database_connection = self.get_connection();
/*
Expected query if there is one single item in "entities":
INSERT INTO library_item (id, name, type) VALUES (?1, ?2, ?3);
Expected query if there are two items in "entities":
INSERT INTO library_item (id, name, type) VALUES (?1, ?2, ?3), ($4, $5, $6);
*/
let mut prepared_statement = database_connection
.prepare(
"INSERT INTO library_item (
id,
name,
type,
) VALUES (?1, ?2, ?3);",
)
.expect("Unable to prepare statement for user saving…");
prepared_statement.execute(rusqlite::params![
entity.id.to_string(),
entity.name,
entity.r#type
]).expect("Unable to insert the library items.");
Ok(())
}
}