blob: de93f51a60aa6a3d115bc346f1e7881d345d5779 (
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::{sqlite::Sqlite, SqliteConnection, Transaction};
pub trait Provider {
fn setup(&mut self) -> Setup;
}
impl<'c> Provider for Transaction<'c, Sqlite> {
fn setup(&mut self) -> Setup {
Setup(self)
}
}
pub struct Setup<'t>(&'t mut SqliteConnection);
impl<'c> Setup<'c> {
pub async fn completed(&mut self) -> Result<bool, sqlx::Error> {
let completed = sqlx::query_scalar!(
r#"
select count(*) > 0 as "completed: bool"
from login
"#,
)
.fetch_one(&mut *self.0)
.await?;
Ok(completed)
}
}
|