summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob L. Kreuze <zerodaysfordays@sdf.org>2020-05-18 11:59:54 -0400
committerJakob L. Kreuze <zerodaysfordays@sdf.org>2020-05-18 11:59:54 -0400
commitd831a9340652f8a259c0764788b8914b6204beac (patch)
treece781434ae4c82a341d4e5943bc49378d5299574
parentfbbf4d617395774e77098fd0a10aad7d0b619a2e (diff)
Implement `tag_image`.
-rw-r--r--src/main.rs13
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() {