admin/roles: view, archive and restore
This commit is contained in:
parent
8fa2fb7ddc
commit
d778380d8b
10 changed files with 363 additions and 2 deletions
|
|
@ -31,4 +31,28 @@ impl Roles {
|
|||
.await
|
||||
.map_err(handle_error)
|
||||
}
|
||||
|
||||
pub async fn get_one_by_name(
|
||||
conn: impl SqliteExecutor<'_>,
|
||||
name: &str,
|
||||
) -> Result<Option<Self>, Error> {
|
||||
sqlx::query_file_as!(Self, "queries/roles/get_one_by_name.sql", name)
|
||||
.fetch_optional(conn)
|
||||
.await
|
||||
.map_err(handle_error)
|
||||
}
|
||||
|
||||
pub async fn set_archive_status(
|
||||
conn: impl SqliteExecutor<'_>,
|
||||
id: &str,
|
||||
value: bool,
|
||||
) -> Result<Option<()>, Error> {
|
||||
let query: SqliteQueryResult =
|
||||
sqlx::query_file!("queries/roles/set_archive_status.sql", value, id)
|
||||
.execute(conn)
|
||||
.await
|
||||
.map_err(handle_error)?;
|
||||
|
||||
Ok((query.rows_affected() == 1).then_some(()))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue