Files
axum-async-graphql/src/domain/typ/repository/typ_update.rs
2026-06-04 23:12:32 +02:00

29 lines
700 B
Rust

use anyhow::Error;
use super::Repository;
use crate::database::Queryer;
use crate::domain::typ::{entity, model};
impl Repository {
pub async fn typ_update<'c, C: Queryer<'c>>(
&self,
db: C,
typ: &entity::TypUpdate,
) -> Result<model::Typ, Error> {
const QUERY: &str = r#"
UPDATE typen
SET typname = $2, geaendert_am = $3 WHERE id = $1
RETURNING id, typname, erstellt_am, geaendert_am;
"#;
let typ = sqlx::query_as::<_, model::Typ>(QUERY)
.bind(typ.id)
.bind(&typ.typname)
.bind(typ.geaendert_am)
.fetch_one(db)
.await?;
Ok(typ)
}
}