use trap::tap::IdentityStatus; pub fn archive_record<'a>( did: &'a str, collection: &'a str, rkey: &'a str, ) -> sqlx::query::Query<'a, sqlx::Postgres, sqlx::postgres::PgArguments> { sqlx::query!( "INSERT INTO deleted_record (SELECT did, collection, rkey, rev, cid, live, data FROM record WHERE (did, collection, rkey) = ($1, $2, $3))", did, collection, rkey, ) } pub fn delete_record<'a>( did: &'a str, collection: &'a str, rkey: &'a str, ) -> sqlx::query::Query<'a, sqlx::Postgres, sqlx::postgres::PgArguments> { sqlx::query!( "DELETE FROM record WHERE (did, collection, rkey) = ($1, $2, $3)", did, collection, rkey, ) } pub fn upsert_identity<'a>( did: &'a str, handle: &'a str, status: &'a IdentityStatus, is_active: bool, ) -> sqlx::query::Query<'a, sqlx::Postgres, sqlx::postgres::PgArguments> { sqlx::query!( "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)", did, handle, is_active, status as &IdentityStatus ) }