at main 1.3 kB view raw
1use trap::tap::IdentityStatus; 2 3pub fn archive_record<'a>( 4 did: &'a str, 5 collection: &'a str, 6 rkey: &'a str, 7) -> sqlx::query::Query<'a, sqlx::Postgres, sqlx::postgres::PgArguments> { 8 sqlx::query!( 9 "INSERT INTO deleted_record (SELECT did, collection, rkey, rev, cid, live, data FROM record WHERE (did, collection, rkey) = ($1, $2, $3))", 10 did, 11 collection, 12 rkey, 13 ) 14} 15 16pub fn delete_record<'a>( 17 did: &'a str, 18 collection: &'a str, 19 rkey: &'a str, 20) -> sqlx::query::Query<'a, sqlx::Postgres, sqlx::postgres::PgArguments> { 21 sqlx::query!( 22 "DELETE FROM record WHERE (did, collection, rkey) = ($1, $2, $3)", 23 did, 24 collection, 25 rkey, 26 ) 27} 28 29pub fn upsert_identity<'a>( 30 did: &'a str, 31 handle: &'a str, 32 status: &'a IdentityStatus, 33 is_active: bool, 34) -> sqlx::query::Query<'a, sqlx::Postgres, sqlx::postgres::PgArguments> { 35 sqlx::query!( 36 "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)", 37 did, 38 handle, 39 is_active, 40 status as &IdentityStatus 41 ) 42}