From d0a9063631e71928484a698f6c585ebb3915e8a2 Mon Sep 17 00:00:00 2001 From: Joris Date: Sun, 9 Jan 2022 14:37:35 +0100 Subject: Allow to update events --- src/db/mod.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/db') 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> { let mut stmt = conn.prepare("SELECT id, date, start, end, name FROM events")?; -- cgit v1.2.3