Start to implement the save_all method.
This commit is contained in:
@@ -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(())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user