Files
axum-async-graphql/src/domain/typ/repository/typ_update.rs

29 lines
700 B
Rust
Raw Normal View History

2026-05-31 20:24:10 +02:00
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,
2026-06-03 22:08:44 +02:00
typ: &entity::TypUpdate,
2026-05-31 20:24:10 +02:00
) -> Result<model::Typ, Error> {
const QUERY: &str = r#"
UPDATE typen
2026-06-04 23:12:32 +02:00
SET typname = $2, geaendert_am = $3 WHERE id = $1
RETURNING id, typname, erstellt_am, geaendert_am;
2026-05-31 20:24:10 +02:00
"#;
let typ = sqlx::query_as::<_, model::Typ>(QUERY)
2026-06-04 22:42:57 +02:00
.bind(typ.id)
2026-05-31 20:24:10 +02:00
.bind(&typ.typname)
2026-06-04 23:12:32 +02:00
.bind(typ.geaendert_am)
2026-05-31 20:24:10 +02:00
.fetch_one(db)
.await?;
Ok(typ)
}
}