From 4bb75656ea2a0083bd2a6504b70e85a81473401a Mon Sep 17 00:00:00 2001 From: Lunae Somnia Date: Sun, 24 Dec 2023 19:31:22 +0100 Subject: [PATCH] fill tag database methods --- src/database/tags.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/database/tags.rs b/src/database/tags.rs index b354cbb..3a2ff32 100644 --- a/src/database/tags.rs +++ b/src/database/tags.rs @@ -65,7 +65,14 @@ impl DatabaseTagHandler for Database { } fn insert_tag(&mut self, tag: Tag) -> Result<(), DatabaseError> { - todo!() + if let Some(connection) = self.get_connection() { + connection.execute( + "INSERT INTO tags (id, name, color) VALUES (?1, ?2, ?3)", + (tag.id, tag.name, tag.color), + )?; + } + + Ok(()) } fn assign_tag_to_audio_file( @@ -73,7 +80,14 @@ impl DatabaseTagHandler for Database { tag: TagID, audio_file: AudioFileID, ) -> Result<(), DatabaseError> { - todo!() + if let Some(connection) = self.get_connection() { + connection.execute( + "INSERT INTO audio_files_tags (audio_file, tags) VALUES (?1, ?2)", + (audio_file, tag), + )?; + } + + Ok(()) } }