fix: post page panic

This commit is contained in:
trisua 2025-04-12 22:42:57 -04:00
parent 7960484bf9
commit 9d091d5421
5 changed files with 26 additions and 2 deletions

View file

@ -551,6 +551,27 @@ macro_rules! auto_method {
}
};
($name:ident($x:ty)@$select_fn:ident -> $query:literal --cache-key-tmpl=$cache_key_tmpl:ident) => {
pub async fn $name(&self, id: usize, x: $x) -> Result<()> {
let y = self.$select_fn(id).await?;
let conn = match self.connect().await {
Ok(c) => c,
Err(e) => return Err(Error::DatabaseConnection(e.to_string())),
};
let res = execute!(&conn, $query, params![&x, &(id as i64)]);
if let Err(e) = res {
return Err(Error::DatabaseError(e.to_string()));
}
self.$cache_key_tmpl(&y).await;
Ok(())
}
};
($name:ident($x:ty)@$select_fn:ident -> $query:literal --serde --cache-key-tmpl=$cache_key_tmpl:ident) => {
pub async fn $name(&self, id: usize, x: $x) -> Result<()> {
let y = self.$select_fn(id).await?;