Skip to content

Commit

Permalink
chore: log client database actions (#207)
Browse files Browse the repository at this point in the history
  • Loading branch information
chris13524 committed Sep 21, 2023
1 parent e0d8a39 commit 2180574
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/stores/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use {
},
async_trait::async_trait,
sqlx::Executor,
tracing::info,
};

#[derive(Debug, Clone, PartialEq, Eq, sqlx::FromRow)]
Expand All @@ -25,6 +26,11 @@ pub trait ClientStore {
#[async_trait]
impl ClientStore for sqlx::PgPool {
async fn create_client(&self, tenant_id: &str, id: &str, client: Client) -> stores::Result<()> {
info!(
"ClientStore::create_client tenant_id={tenant_id} id={id} token={}",
client.token
);

let mut transaction = self.begin().await?;

sqlx::query("DELETE FROM public.clients WHERE id = $1 OR device_token = $2")
Expand Down Expand Up @@ -69,6 +75,8 @@ impl ClientStore for sqlx::PgPool {
}

async fn delete_client(&self, tenant_id: &str, id: &str) -> stores::Result<()> {
info!("ClientStore::delete_client tenant_id={tenant_id} id={id}");

let mut notification_query_builder =
sqlx::QueryBuilder::new("DELETE FROM public.notifications WHERE client_id = ");
notification_query_builder.push_bind(id);
Expand Down

0 comments on commit 2180574

Please sign in to comment.