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

31 lines
809 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_erstellen<'c, C: Queryer<'c>>(
&self,
db: C,
2026-06-03 22:08:44 +02:00
typ: &entity::TypErstellen,
2026-05-31 20:24:10 +02:00
) -> Result<model::Typ, Error> {
const QUERY: &str = r#"
2026-06-03 22:08:44 +02:00
INSERT INTO typen (typ_id, id, erstellt_am, geaendert_am, typname) VALUES (
$1, $2, $3, $4, $5
2026-05-31 20:24:10 +02:00
) RETURNING id, erstellt_am, geaendert_am, typname;
"#;
let typ = sqlx::query_as::<_, model::Typ>(QUERY)
2026-06-03 22:08:44 +02:00
.bind(typ.typ_id)
2026-06-04 22:42:57 +02:00
.bind(typ.id)
2026-05-31 20:24:10 +02:00
.bind(typ.erstellt_am)
.bind(typ.geaendert_am)
.bind(&typ.typname)
.fetch_one(db)
.await?;
Ok(typ)
}
}