implement identity remove action

This commit is contained in:
yggverse 2024-11-29 05:44:40 +02:00
parent 00afa70d5d
commit 29083f50d9
8 changed files with 241 additions and 18 deletions

View file

@ -45,6 +45,22 @@ impl Database {
}
}
/// Delete record with given `id` from database
pub fn delete(&self, id: i64) -> Result<(), Error> {
// Begin new transaction
let mut writable = self.connection.write().unwrap(); // @TODO
let tx = writable.transaction()?;
// Create new record
delete(&tx, id)?;
// Done
match tx.commit() {
Ok(_) => Ok(()),
Err(reason) => Err(reason),
}
}
/// Get single record match `id`
pub fn record(&self, id: i64) -> Result<Option<Table>, Error> {
let readable = self.connection.read().unwrap();
@ -94,6 +110,10 @@ pub fn insert(tx: &Transaction, profile_identity_id: i64, pem: &str) -> Result<u
)
}
pub fn delete(tx: &Transaction, id: i64) -> Result<usize, Error> {
tx.execute("DELETE FROM `profile_identity_gemini` WHERE `id` = ?", [id])
}
pub fn select(tx: &Transaction, profile_identity_id: i64) -> Result<Vec<Table>, Error> {
let mut stmt = tx.prepare(
"SELECT `id`,