Skip to main content

backbone_bucket/infrastructure/persistence/
content_hash_repository.rs

1//! Repository for ContentHash entities
2//!
3//! Generated by metaphor-schema. Do not edit manually.
4//!
5//! Thin newtype over `backbone_orm::GenericCrudRepository<ContentHash, backbone_orm::SoftDelete>`.
6//! All standard CRUD methods are available via `Deref`.
7
8use anyhow::Result;
9use sqlx::PgPool;
10
11use crate::domain::entity::ContentHash;
12
13/// Table name for ContentHash entities
14pub const TABLE_NAME: &str = "bucket.content_hashes";
15
16/// Repository for ContentHash entities.
17///
18/// All standard CRUD, soft-delete, pagination, and bulk methods are
19/// provided automatically via `Deref` to `backbone_orm::GenericCrudRepository`.
20pub struct ContentHashRepository(
21    backbone_orm::GenericCrudRepository<ContentHash, backbone_orm::SoftDelete>,
22);
23
24impl std::ops::Deref for ContentHashRepository {
25    type Target = backbone_orm::GenericCrudRepository<ContentHash, backbone_orm::SoftDelete>;
26    fn deref(&self) -> &Self::Target { &self.0 }
27}
28
29impl ContentHashRepository {
30    /// Create a new repository instance.
31    pub fn new(pool: PgPool) -> Self {
32        Self(backbone_orm::GenericCrudRepository::new(pool, TABLE_NAME))
33    }
34}
35
36impl ContentHashRepository {
37    /// Find content_hash by hash (excludes soft-deleted)
38    pub async fn find_by_hash(&self, hash: &str) -> Result<Option<ContentHash>> {
39        self.find_by_text_field("hash", hash).await
40    }
41
42    /// Check if content_hash exists by hash (excludes soft-deleted)
43    pub async fn exists_by_hash(&self, hash: &str) -> Result<bool> {
44        self.exists_by_text_field("hash", hash).await
45    }
46
47}
48
49backbone_core::impl_crud_repository!(ContentHashRepository, ContentHash, soft_delete);