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