adds the ability to clear db
This commit is contained in:
@@ -222,6 +222,18 @@ impl<'a> Repository<'a> {
|
||||
Ok(message_record.map(|r| r.into()))
|
||||
}
|
||||
|
||||
pub fn delete_all_conversations(&mut self) -> Result<()> {
|
||||
use crate::schema::conversations::dsl::*;
|
||||
diesel::delete(conversations).execute(self.connection)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn delete_all_messages(&mut self) -> Result<()> {
|
||||
use crate::schema::messages::dsl::*;
|
||||
diesel::delete(messages).execute(self.connection)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// Helper function to get the last inserted row ID
|
||||
// This is a workaround since the Sqlite backend doesn't support `RETURNING`
|
||||
// Huge caveat with this is that it depends on whatever the last insert was, prevents concurrent inserts.
|
||||
|
||||
Reference in New Issue
Block a user