apps: get all with filter, serde
This commit is contained in:
parent
842be36a1b
commit
42d88cc2dd
9 changed files with 259 additions and 1 deletions
|
|
@ -7,6 +7,7 @@ edition = "2021"
|
|||
thiserror = { workspace = true }
|
||||
chrono = { workspace = true }
|
||||
url = { workspace = true }
|
||||
serde = { workspace = true }
|
||||
|
||||
# local crates
|
||||
id = { path = "../id" }
|
||||
|
|
|
|||
|
|
@ -22,6 +22,17 @@ impl From<DatabaseApps> for App {
|
|||
}
|
||||
|
||||
impl App {
|
||||
pub async fn get_all(
|
||||
conn: impl SqliteExecutor<'_>,
|
||||
filter_get_archived: Option<bool>,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
Ok(DatabaseApps::get_all(conn, filter_get_archived)
|
||||
.await?
|
||||
.into_iter()
|
||||
.map(Self::from)
|
||||
.collect::<Vec<_>>())
|
||||
}
|
||||
|
||||
pub async fn insert(
|
||||
conn: impl SqliteExecutor<'_>,
|
||||
id: &AppID,
|
||||
|
|
|
|||
|
|
@ -4,11 +4,12 @@ mod get_valid;
|
|||
|
||||
use chrono::{DateTime, Utc};
|
||||
use id::AppID;
|
||||
use serde::Serialize;
|
||||
|
||||
pub use crate::error::Error;
|
||||
pub use get_valid::Error as GetValidError;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Serialize, Debug, Clone)]
|
||||
pub struct App {
|
||||
id: AppID,
|
||||
created_at: DateTime<Utc>,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue