draft add method

This commit is contained in:
yggverse 2024-11-13 08:32:49 +02:00
parent 8679dfc332
commit 096b2c5178

View File

@ -40,6 +40,22 @@ impl Database {
}
None
}
// Setters
pub fn add(&self, is_active: bool, time: &DateTime, name: Option<&str>) -> Result<i64, ()> {
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