aboutsummaryrefslogtreecommitdiff
path: root/src/db
diff options
context:
space:
mode:
authorJoris2022-01-09 14:37:35 +0100
committerJoris2022-01-09 14:37:35 +0100
commitd0a9063631e71928484a698f6c585ebb3915e8a2 (patch)
tree9a5fc430684aea73877711dd3392b1845d4b9904 /src/db
parent5166efe517291f5c9fc6326f30651ef799d6db65 (diff)
Allow to update events
Diffstat (limited to 'src/db')
-rw-r--r--src/db/mod.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/db/mod.rs b/src/db/mod.rs
index 23cec7e..03692e9 100644
--- a/src/db/mod.rs
+++ b/src/db/mod.rs
@@ -21,6 +21,16 @@ pub fn insert(conn: &Connection, event: &Event) -> Result<()> {
Ok(())
}
+pub fn update(conn: &Connection, event: &Event) -> Result<()> {
+ conn.execute(
+ "UPDATE events SET date = ?, start = ?, end = ?, name = ?, updated = datetime() where id = ?",
+ params![event.date, event.start, event.end, event.name, event.id.to_hyphenated().to_string()]
+ )?;
+
+ Ok(())
+}
+
+// TODO: Don’t use unwrap
pub fn list(conn: &Connection) -> Result<Vec<Event>> {
let mut stmt = conn.prepare("SELECT id, date, start, end, name FROM events")?;