Nicer write transaction
This commit is contained in:
parent
f5fc71f388
commit
4d8fc77665
1 changed files with 5 additions and 8 deletions
|
|
@ -178,14 +178,11 @@ impl Database {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn create_write_transaction(&self, vault: &VaultId) -> Result<Transaction<'static>> {
|
pub async fn create_write_transaction(&self, vault: &VaultId) -> Result<Transaction<'static>> {
|
||||||
let mut transaction = self.create_readonly_transaction(vault).await?;
|
self.get_connection_pool(vault)
|
||||||
|
.await?
|
||||||
// sqlx doesn't support immediate transactions for sqlite: https://github.com/launchbadge/sqlx/issues/481
|
.begin_with("BEGIN IMMEDIATE")
|
||||||
sqlx::query("END; BEGIN IMMEDIATE;")
|
.await
|
||||||
.execute(&mut *transaction)
|
.context("Cannot create write transaction")
|
||||||
.await?;
|
|
||||||
|
|
||||||
Ok(transaction)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Cleanup idle connection pools that haven't been accessed in more than 5 minutes
|
/// Cleanup idle connection pools that haven't been accessed in more than 5 minutes
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue