articles_rs/databases/
postgres_repository.rsuse async_trait::async_trait;
use std::collections::HashMap;
use uuid::Uuid;
#[async_trait]
pub trait PostgresRepository {
type Error;
type Item;
async fn find_by_id(&self, id: Uuid) -> Result<Option<Self::Item>, Self::Error>;
async fn find_by_name(&self, name: String) -> Result<Option<Self::Item>, Self::Error>;
async fn list(
&self,
filters: Option<HashMap<String, String>>,
) -> Result<Vec<Self::Item>, Self::Error>;
async fn create(&self, item: &Self::Item) -> Result<Uuid, Self::Error>;
async fn delete(&self, id: Uuid) -> Result<(), Self::Error>;
async fn delete_all(&self, filters: Option<HashMap<String, String>>)
-> Result<(), Self::Error>;
async fn update(&self, item: &Self::Item) -> Result<(), Self::Error>;
}