add typ
This commit is contained in:
28
src/domain/typ/repository/typ_update.rs
Normal file
28
src/domain/typ/repository/typ_update.rs
Normal file
@@ -0,0 +1,28 @@
|
||||
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::Typ,
|
||||
) -> Result<model::Typ, Error> {
|
||||
const QUERY: &str = r#"
|
||||
UPDATE typen
|
||||
SET geaendert_am = $2, typname = $3 WHERE id = $1
|
||||
RETURNING id, erstellt_am, geaendert_am, typname;
|
||||
"#;
|
||||
|
||||
let typ = sqlx::query_as::<_, model::Typ>(QUERY)
|
||||
.bind(typ.id)
|
||||
.bind(typ.geaendert_am)
|
||||
.bind(&typ.typname)
|
||||
.fetch_one(db)
|
||||
.await?;
|
||||
|
||||
Ok(typ)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user