(&self, f: F)
| 77 | } |
| 78 | |
| 79 | pub async fn transaction<F, T, Fut>(&self, f: F) -> Result<T, DatabaseError> |
| 80 | where |
| 81 | F: FnOnce(&mut SqliteTransaction<'_>) -> Fut, |
| 82 | Fut: Future<Output = Result<T, DatabaseError>>, |
| 83 | { |
| 84 | let mut tx = self.begin().await?; |
| 85 | let result = f(&mut tx).await?; |
| 86 | tx.commit() |
| 87 | .await |
| 88 | .map_err(|e| DatabaseError::TransactionError(e.to_string()))?; |
| 89 | Ok(result) |
| 90 | } |
| 91 | |
| 92 | pub async fn get_connection(&self) -> Result<SqliteConnection, DatabaseError> { |
| 93 | self.pool |