mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-15 17:20:08 +00:00
draft add method
This commit is contained in:
parent
8679dfc332
commit
096b2c5178
@ -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…
x
Reference in New Issue
Block a user