use async_trait::async_trait;
use business::domain::shared::pagination::{Page, PageRequest};
use business::domain::shared::repository_error::RepositoryError;
use business::domain::{{ snake }}::{
model::{{ "{" }}{{ pascal }}, {{ pascal }}Id},
repository::{{ pascal }}RepositoryTrait,
};
/// A stand-in that stores nothing — replace it with a real adapter (`puerto new --db` generates
/// Postgres repositories).
#[derive(Default)]
pub struct InMemory{{ pascal }}Repository;
impl InMemory{{ pascal }}Repository {
pub fn new() -> Self {
Self
}
}
#[async_trait]
impl {{ pascal }}RepositoryTrait for InMemory{{ pascal }}Repository {
async fn find_all(&self, page: PageRequest) -> Result<Page<{{ pascal }}>, RepositoryError> {
tracing::debug!(limit = page.limit(), offset = page.offset(), "find_all");
Ok(Page::new(vec![], 0, page))
}
async fn find_by_id(&self, id: {{ pascal }}Id) -> Result<Option<{{ pascal }}>, RepositoryError> {
tracing::debug!(%id, "find_by_id");
Ok(None)
}
async fn save(&self, entity: &{{ pascal }}) -> Result<(), RepositoryError> {
tracing::debug!(id = %entity.id, "save");
Ok(())
}
}