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