diff options
| author | Jakob L. Kreuze <zerodaysfordays@sdf.org> | 2020-05-28 19:58:23 -0400 |
|---|---|---|
| committer | Jakob L. Kreuze <zerodaysfordays@sdf.org> | 2020-05-28 19:58:23 -0400 |
| commit | c4939e02b80bf857419a257be316b5f87eae3445 (patch) | |
| tree | 132545095d855a3e55c5a7b997ef4bd9ade129ed /src/database.rs | |
| parent | 2d8035f4724f38875d0f29faa1069772d6aadb79 (diff) | |
Implement per-image information and display.
Diffstat (limited to 'src/database.rs')
| -rw-r--r-- | src/database.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/database.rs b/src/database.rs index 055d1ef..54f511f 100644 --- a/src/database.rs +++ b/src/database.rs @@ -128,6 +128,25 @@ impl TagDatabase { .query_row(params![path, file_name], |row| Ok(row.get::<_, i64>(0)))??) } + /// Return the `Image` struct for the image with `id`. + pub fn image_by_id(&self, id: i64) -> Result<Image> { + Ok(self + .0 + .prepare( + "SELECT id, blake2, filename, orig_dir + FROM images + WHERE id = ?", + )? + .query_row(params![id], |row| { + Ok(Image { + id: row.get(0)?, + blake2: row.get(1)?, + filename: row.get(2)?, + orig_dir: row.get(3)?, + }) + })?) + } + /// Associate `tag` with the image specified by `image_id`. pub fn tag_image(&self, image_id: i64, tag: &str) -> Result<()> { self.0.execute( |