use anyhow::Result;
use sqlx::PgPool;
use crate::domain::entity::ContentHash;
pub const TABLE_NAME: &str = "bucket.content_hashes";
pub struct ContentHashRepository(
backbone_orm::GenericCrudRepository<ContentHash, backbone_orm::SoftDelete>,
);
impl std::ops::Deref for ContentHashRepository {
type Target = backbone_orm::GenericCrudRepository<ContentHash, backbone_orm::SoftDelete>;
fn deref(&self) -> &Self::Target { &self.0 }
}
impl ContentHashRepository {
pub fn new(pool: PgPool) -> Self {
Self(backbone_orm::GenericCrudRepository::new(pool, TABLE_NAME))
}
}
impl ContentHashRepository {
pub async fn find_by_hash(&self, hash: &str) -> Result<Option<ContentHash>> {
self.find_by_text_field("hash", hash).await
}
pub async fn exists_by_hash(&self, hash: &str) -> Result<bool> {
self.exists_by_text_field("hash", hash).await
}
}
backbone_core::impl_crud_repository!(ContentHashRepository, ContentHash, soft_delete);