enable changing paid state

This commit is contained in:
2024-01-22 19:05:18 +01:00
parent ac5ecbafec
commit eda072c713
4 changed files with 132 additions and 37 deletions

View File

@@ -3,8 +3,8 @@ use sqlx::{FromRow, SqlitePool};
#[derive(FromRow, Serialize, Clone)]
pub struct Role {
id: i64,
name: String,
pub(crate) id: i64,
pub(crate) name: String,
}
impl Role {
@@ -30,6 +30,21 @@ WHERE id like ?
.ok()
}
pub async fn find_by_name(db: &SqlitePool, name: &str) -> Option<Self> {
sqlx::query_as!(
Self,
"
SELECT id, name
FROM role
WHERE name like ?
",
name
)
.fetch_one(db)
.await
.ok()
}
pub async fn mails_from_role(&self, db: &SqlitePool) -> Vec<String> {
let query = format!(
"SELECT u.mail