use anyhow::Result;
use sqlx::PgPool;
use crate::domain::entity::PhoneBlacklist;
pub const TABLE_NAME: &str = "messaging.phone_blacklists";
pub struct PhoneBlacklistRepository(
backbone_orm::GenericCrudRepository<PhoneBlacklist, backbone_orm::SoftDelete>,
);
impl std::ops::Deref for PhoneBlacklistRepository {
type Target = backbone_orm::GenericCrudRepository<PhoneBlacklist, backbone_orm::SoftDelete>;
fn deref(&self) -> &Self::Target { &self.0 }
}
impl PhoneBlacklistRepository {
pub fn new(pool: PgPool) -> Self {
Self(backbone_orm::GenericCrudRepository::new(pool, TABLE_NAME))
}
}
impl PhoneBlacklistRepository {
pub async fn find_by_number(&self, number: &str) -> Result<Option<PhoneBlacklist>> {
self.find_by_text_field("number", number).await
}
pub async fn exists_by_number(&self, number: &str) -> Result<bool> {
self.exists_by_text_field("number", number).await
}
}
backbone_core::impl_crud_repository!(PhoneBlacklistRepository, PhoneBlacklist, soft_delete);