aboutsummaryrefslogtreecommitdiff
path: root/src/db
diff options
context:
space:
mode:
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")?;