Skip to main content

systemprompt_users/repository/
mod.rs

1mod api_key;
2mod banned_ip;
3mod device_cert;
4mod federated_identity;
5mod user;
6
7pub use api_key::CreateApiKeyParams;
8pub use banned_ip::{
9    BanDuration, BanIpParams, BanIpWithMetadataParams, BannedIp, BannedIpRepository,
10};
11pub use device_cert::EnrollDeviceCertParams;
12pub use user::{MergeResult, UpdateUserParams};
13
14use crate::error::Result;
15use sqlx::PgPool;
16use std::sync::Arc;
17use systemprompt_database::DbPool;
18
19const MAX_PAGE_SIZE: i64 = 100;
20
21#[derive(Debug, Clone)]
22pub struct UserRepository {
23    pool: Arc<PgPool>,
24    write_pool: Arc<PgPool>,
25}
26
27impl UserRepository {
28    pub fn new(db: &DbPool) -> Result<Self> {
29        let pool = db.pool_arc()?;
30        let write_pool = db.write_pool_arc()?;
31        Ok(Self { pool, write_pool })
32    }
33}