summaryrefslogtreecommitdiff
path: root/makima/src/db/repository.rs
diff options
context:
space:
mode:
Diffstat (limited to 'makima/src/db/repository.rs')
-rw-r--r--makima/src/db/repository.rs85
1 files changed, 0 insertions, 85 deletions
diff --git a/makima/src/db/repository.rs b/makima/src/db/repository.rs
index 5a912e4..57e8a78 100644
--- a/makima/src/db/repository.rs
+++ b/makima/src/db/repository.rs
@@ -6698,88 +6698,3 @@ pub async fn get_available_orders_for_dog_pickup(
.await
}
-// =============================================================================
-// User Settings
-// =============================================================================
-
-/// Get all settings for a user.
-pub async fn get_user_settings(
- pool: &PgPool,
- owner_id: Uuid,
-) -> Result<Vec<UserSetting>, sqlx::Error> {
- sqlx::query_as::<_, UserSetting>(
- r#"
- SELECT id, owner_id, key, value, created_at, updated_at
- FROM user_settings
- WHERE owner_id = $1
- ORDER BY key ASC
- "#,
- )
- .bind(owner_id)
- .fetch_all(pool)
- .await
-}
-
-/// Get a specific setting by key for a user.
-pub async fn get_user_setting(
- pool: &PgPool,
- owner_id: Uuid,
- key: &str,
-) -> Result<Option<UserSetting>, sqlx::Error> {
- sqlx::query_as::<_, UserSetting>(
- r#"
- SELECT id, owner_id, key, value, created_at, updated_at
- FROM user_settings
- WHERE owner_id = $1 AND key = $2
- "#,
- )
- .bind(owner_id)
- .bind(key)
- .fetch_optional(pool)
- .await
-}
-
-/// Upsert (create or update) a user setting.
-pub async fn upsert_user_setting(
- pool: &PgPool,
- owner_id: Uuid,
- key: &str,
- value: &serde_json::Value,
-) -> Result<UserSetting, sqlx::Error> {
- sqlx::query_as::<_, UserSetting>(
- r#"
- INSERT INTO user_settings (owner_id, key, value)
- VALUES ($1, $2, $3)
- ON CONFLICT (owner_id, key) DO UPDATE SET
- value = EXCLUDED.value,
- updated_at = NOW()
- RETURNING id, owner_id, key, value, created_at, updated_at
- "#,
- )
- .bind(owner_id)
- .bind(key)
- .bind(value)
- .fetch_one(pool)
- .await
-}
-
-/// Delete a user setting by key. Returns true if a row was deleted.
-pub async fn delete_user_setting(
- pool: &PgPool,
- owner_id: Uuid,
- key: &str,
-) -> Result<bool, sqlx::Error> {
- let result = sqlx::query(
- r#"
- DELETE FROM user_settings
- WHERE owner_id = $1 AND key = $2
- "#,
- )
- .bind(owner_id)
- .bind(key)
- .execute(pool)
- .await?;
-
- Ok(result.rows_affected() > 0)
-}
-