systemprompt_users/repository/
mod.rs1mod api_key;
13mod banned_ip;
14mod device_cert;
15mod federated_identity;
16mod user;
17
18pub use api_key::CreateApiKeyParams;
19pub use banned_ip::{
20 BanDuration, BanIpParams, BanIpWithMetadataParams, BannedIp, BannedIpRepository,
21};
22pub use device_cert::EnrollDeviceCertParams;
23pub use user::{MergeResult, UpdateUserParams};
24
25use crate::error::Result;
26use sqlx::PgPool;
27use std::sync::Arc;
28use systemprompt_database::DbPool;
29
30const MAX_PAGE_SIZE: i64 = 100;
31
32#[derive(Debug, Clone)]
33pub struct UserRepository {
34 pool: Arc<PgPool>,
35 write_pool: Arc<PgPool>,
36}
37
38impl UserRepository {
39 pub fn new(db: &DbPool) -> Result<Self> {
40 let pool = db.pool_arc()?;
41 let write_pool = db.write_pool_arc()?;
42 Ok(Self { pool, write_pool })
43 }
44}