From 096b2c517809cc291a8c3fd88e9ac8a2a599fecd Mon Sep 17 00:00:00 2001 From: yggverse Date: Wed, 13 Nov 2024 08:32:49 +0200 Subject: [PATCH] draft add method --- src/profile/database.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/profile/database.rs b/src/profile/database.rs index d39d25f1..bf4be04d 100644 --- a/src/profile/database.rs +++ b/src/profile/database.rs @@ -40,6 +40,22 @@ impl Database { } None } + + // Setters + + pub fn add(&self, is_active: bool, time: &DateTime, name: Option<&str>) -> Result { + let mut writable = self.connection.write().unwrap(); + let tx = writable.transaction().unwrap(); + + add(&tx, is_active, time, name).unwrap(); + + let id = last_insert_id(&tx); + + match tx.commit() { + Ok(_) => Ok(id), + Err(_) => Err(()), // @TODO + } + } } // Low-level DB API