mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 17:15:28 +00:00
draft add method
This commit is contained in:
parent
8679dfc332
commit
096b2c5178
1 changed files with 16 additions and 0 deletions
|
|
@ -40,6 +40,22 @@ impl Database {
|
||||||
}
|
}
|
||||||
None
|
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
|
// Low-level DB API
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue