gearbox_rs_postgres/
repository.rs1use crate::{PgEntity, PgError};
2
3#[gearbox_rs_core::async_trait]
29pub trait PgRepository<T: PgEntity>: Send + Sync {
30 async fn create(&self, entity: T) -> Result<T, PgError>;
31 async fn upsert(&self, entity: T) -> Result<T, PgError>;
32 async fn update(&self, entity: T) -> Result<T, PgError>;
33 async fn find_by_id(&self, id: &T::Id) -> Result<Option<T>, PgError>;
34 async fn find_by_ids(&self, ids: &[T::Id]) -> Result<Vec<T>, PgError>;
35 async fn find_page(&self, limit: i64, offset: i64) -> Result<Vec<T>, PgError>;
36 async fn exists(&self, id: &T::Id) -> Result<bool, PgError>;
37 async fn count(&self) -> Result<i64, PgError>;
38 async fn delete(&self, id: &T::Id) -> Result<bool, PgError>;
39 async fn delete_batch(&self, ids: &[T::Id]) -> Result<u64, PgError>;
40 async fn create_batch(&self, entities: Vec<T>) -> Result<Vec<T>, PgError>;
41 async fn upsert_batch(&self, entities: Vec<T>) -> Result<Vec<T>, PgError>;
42}