diff options
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs index e7febe4..3e821c2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -88,6 +88,19 @@ impl TagBase { } Ok(()) } + + /// Associate `tag` with the image specified by `image_id`. + fn tag_image(&self, image_id: i64, tag: &str) -> Result<()> { + let tag_id: i64 = self + .conn + .prepare("SELECT * FROM tags WHERE name = ?")? + .query_row(params![tag], |row| Ok(row.get(0)))??; + self.conn.execute( + "INSERT INTO mapping (image, tag) VALUES(?, ?)", + params![image_id, tag_id], + )?; + Ok(()) + } } fn main() { |