mirror of
https://github.com/Diggsey/sqlxmq.git
synced 2024-11-22 00:01:00 +00:00
feat: function to check if a job id exists
This commit is contained in:
parent
6d3ed6fb99
commit
6fde3901a4
1 changed files with 12 additions and 0 deletions
12
src/spawn.rs
12
src/spawn.rs
|
@ -171,3 +171,15 @@ pub async fn clear_all<'b, E: sqlx::Executor<'b, Database = Postgres>>(
|
||||||
.await?;
|
.await?;
|
||||||
Ok(())
|
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)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue