18 lines
345 B
Rust
18 lines
345 B
Rust
|
use serde::Serialize;
|
||
|
use sqlx::{FromRow, SqlitePool};
|
||
|
|
||
|
#[derive(FromRow, Serialize, Clone)]
|
||
|
pub struct Role {
|
||
|
id: i64,
|
||
|
name: String,
|
||
|
}
|
||
|
|
||
|
impl Role {
|
||
|
pub async fn all(db: &SqlitePool) -> Vec<Role> {
|
||
|
sqlx::query_as!(Role, "SELECT id, name FROM role")
|
||
|
.fetch_all(db)
|
||
|
.await
|
||
|
.unwrap()
|
||
|
}
|
||
|
}
|