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