Tap drinker
1use trap::tap::IdentityStatus;
2
3pub fn delete_record<'a>(
4 did: &'a str,
5 collection: &'a str,
6 rkey: &'a str,
7 rev: &'a str,
8) -> sqlx::query::Query<'a, sqlx::Postgres, sqlx::postgres::PgArguments> {
9 sqlx::query!(
10 "DELETE FROM record WHERE (did, collection, rkey) = ($1, $2, $3) AND rev <= $4",
11 did,
12 collection,
13 rkey,
14 rev
15 )
16}
17
18pub fn upsert_identity<'a>(
19 did: &'a str,
20 handle: &'a str,
21 status: &'a IdentityStatus,
22 is_active: bool,
23) -> sqlx::query::Query<'a, sqlx::Postgres, sqlx::postgres::PgArguments> {
24 sqlx::query!(
25 "INSERT INTO identity (did, handle, active, status) VALUES ($1, $2, $3, $4) ON CONFLICT ON CONSTRAINT identity_pkey DO UPDATE SET (handle, active, status) = (EXCLUDED.handle, EXCLUDED.active, EXCLUDED.status)",
26 did,
27 handle,
28 is_active,
29 status as &IdentityStatus
30 )
31}