diff options
author | Joris | 2022-04-24 16:31:49 +0200 |
---|---|---|
committer | Joris | 2022-04-24 16:31:49 +0200 |
commit | 47fe90ee23d8ab04645ef3c7a17459ed40c5b765 (patch) | |
tree | d1aa7d3840a3bd825dcae0a0398fec7ca310f45c /src/db/event_color.rs | |
parent | 6d271b09303d924381cc65e7c0b5eb56833780ed (diff) |
Allow to attach categories to events
Diffstat (limited to 'src/db/event_color.rs')
-rw-r--r-- | src/db/event_color.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/db/event_color.rs b/src/db/event_color.rs new file mode 100644 index 0000000..33d350b --- /dev/null +++ b/src/db/event_color.rs @@ -0,0 +1,14 @@ +use anyhow::Result; +use rusqlite::Connection; + +pub fn get_default_color(conn: &Connection) -> Result<String> { + let mut stmt = conn.prepare("SELECT * FROM event_color LIMIT 1")?; + + let iter = stmt.query_map([], |row| row.get(0))?; + + let mut res = vec![]; + for color in iter { + res.push(color?) + } + Ok(res.first().unwrap_or(&"blue".to_string()).clone()) +} |