apps: get all with filter, serde
This commit is contained in:
parent
842be36a1b
commit
42d88cc2dd
9 changed files with 259 additions and 1 deletions
|
|
@ -16,6 +16,35 @@ pub struct Apps {
|
|||
}
|
||||
|
||||
impl Apps {
|
||||
pub async fn get_all(
|
||||
conn: impl SqliteExecutor<'_>,
|
||||
filter_get_archived: Option<bool>,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
match filter_get_archived {
|
||||
Some(true) => {
|
||||
// Get all archived apps
|
||||
sqlx::query_file_as!(Self, "queries/apps/get_all_archived.sql")
|
||||
.fetch_all(conn)
|
||||
.await
|
||||
.map_err(handle_error)
|
||||
}
|
||||
Some(false) => {
|
||||
// Get all active apps
|
||||
sqlx::query_file_as!(Self, "queries/apps/get_all_active.sql")
|
||||
.fetch_all(conn)
|
||||
.await
|
||||
.map_err(handle_error)
|
||||
}
|
||||
None => {
|
||||
// Get all apps
|
||||
sqlx::query_file_as!(Self, "queries/apps/get_all.sql")
|
||||
.fetch_all(conn)
|
||||
.await
|
||||
.map_err(handle_error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn insert(
|
||||
conn: impl SqliteExecutor<'_>,
|
||||
id: &str,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue