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