Delete account

This commit is contained in:
Hanh 2021-09-10 17:54:55 +08:00
parent 7d1c1912f7
commit d056567dc6
2 changed files with 12 additions and 0 deletions

View File

@ -730,6 +730,13 @@ impl DbAdapter {
self.connection.execute("DELETE FROM transactions", NO_PARAMS)?;
Ok(())
}
pub fn delete_account(&self, account: u32) -> anyhow::Result<()> {
self.connection.execute("DELETE FROM received_notes WHERE account = ?1", params![account])?;
self.connection.execute("DELETE FROM accounts WHERE id_account = ?1", params![account])?;
self.connection.execute("DELETE FROM taddrs WHERE account = ?1", params![account])?;
Ok(())
}
}
#[cfg(test)]

View File

@ -502,6 +502,11 @@ impl Wallet {
Ok(quotes.len() as u32)
}
pub fn delete_account(&self, account: u32) -> anyhow::Result<()> {
self.db.delete_account(account)?;
Ok(())
}
pub fn truncate_data(&self) -> anyhow::Result<()> {
self.db.truncate_data()
}