use sqlx::PgPool; use uuid::Uuid; pub struct ImageRowMin { pub fid: String, pub url_path: String, } pub async fn fetch_min(pool: &PgPool, id: Uuid) -> Result, sqlx::Error> { let row: Option<(String, String)> = sqlx::query_as("SELECT fid, url_path FROM images WHERE id = $1") .bind(id) .fetch_optional(pool) .await?; Ok(row.map(|(fid, url_path)| ImageRowMin { fid, url_path })) } pub async fn delete(pool: &PgPool, id: Uuid) -> Result { let r = sqlx::query("DELETE FROM images WHERE id = $1") .bind(id) .execute(pool) .await?; Ok(r.rows_affected()) } pub async fn mark_pending_gc(pool: &PgPool, id: Uuid) -> Result<(), sqlx::Error> { sqlx::query( "UPDATE images SET meta = meta || '{\"pending_gc\":true}'::jsonb WHERE id = $1", ) .bind(id) .execute(pool) .await?; Ok(()) }