feat: function to check if a job id exists

This commit is contained in:
Flix 2022-02-05 15:29:53 +01:00
parent 6d3ed6fb99
commit 6fde3901a4
No known key found for this signature in database
GPG key ID: EBB619189E801730

View file

@ -171,3 +171,15 @@ pub async fn clear_all<'b, E: sqlx::Executor<'b, Database = Postgres>>(
.await?;
Ok(())
}
/// Check if a job with that ID exists
pub async fn exists<'b, E: sqlx::Executor<'b, Database = Postgres>>(
executor: E,
id: Uuid,
) -> Result<bool, sqlx::Error> {
let exists = sqlx::query_scalar("SELECT EXISTS(SELECT id FROM mq_msgs WHERE id = $1)")
.bind(id)
.fetch_one(executor)
.await?;
Ok(exists)
}