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, typ: &entity::Typ, ) -> Result { const QUERY: &str = r#" INSERT INTO typen (id, erstellt_am, geaendert_am, typname) VALUES ( $1, $2, $3, $4 ) RETURNING id, erstellt_am, geaendert_am, typname; "#; let typ = sqlx::query_as::<_, model::Typ>(QUERY) .bind(typ.id) .bind(typ.erstellt_am) .bind(typ.geaendert_am) .bind(&typ.typname) .fetch_one(db) .await?; Ok(typ) } }