blob: e7c61f253ad89d83de3bb401f94cd9f200191a3c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
use sqlx::{SqliteConnection, Transaction, sqlite::Sqlite};
pub trait Provider {
fn setup(&mut self) -> Setup<'_>;
}
impl Provider for Transaction<'_, Sqlite> {
fn setup(&mut self) -> Setup<'_> {
Setup(self)
}
}
pub struct Setup<'t>(&'t mut SqliteConnection);
impl Setup<'_> {
pub async fn completed(&mut self) -> Result<bool, sqlx::Error> {
let completed = sqlx::query_scalar!(
r#"
select count(*) > 0 as "completed: bool"
from user
"#,
)
.fetch_one(&mut *self.0)
.await?;
Ok(completed)
}
}
|