first commit
This commit is contained in:
commit
2a1854ab08
120 files changed
+11300
No files matched your search
@@ -0,0 +1,34 @@
|
||||
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<Option<ImageRowMin>, 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<u64, sqlx::Error> {
|
||||
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(())
|
||||
}
|
||||
Reference in new issue
Block a user