backbone-mail 0.2.32

Odoo mail core port — message/notification/followers/activity/alias/sms queue (schema: messaging)
//! Repository for MailAttachment entities
//!
//! Generated by metaphor-schema. Do not edit manually.
//!
//! Thin newtype over `backbone_orm::GenericCrudRepository<MailAttachment, backbone_orm::SoftDelete>`.
//! All standard CRUD methods are available via `Deref`.

use anyhow::Result;
use sqlx::PgPool;
use uuid::Uuid;

use crate::domain::entity::MailAttachment;

/// Table name for MailAttachment entities
pub const TABLE_NAME: &str = "messaging.mail_attachments";

/// Repository for MailAttachment entities.
///
/// All standard CRUD, soft-delete, pagination, and bulk methods are
/// provided automatically via `Deref` to `backbone_orm::GenericCrudRepository`.
pub struct MailAttachmentRepository(
    backbone_orm::GenericCrudRepository<MailAttachment, backbone_orm::SoftDelete>,
);

impl std::ops::Deref for MailAttachmentRepository {
    type Target = backbone_orm::GenericCrudRepository<MailAttachment, backbone_orm::SoftDelete>;
    fn deref(&self) -> &Self::Target { &self.0 }
}

impl MailAttachmentRepository {
    /// Create a new repository instance.
    pub fn new(pool: PgPool) -> Self {
        Self(backbone_orm::GenericCrudRepository::new(pool, TABLE_NAME))
    }
}

impl MailAttachmentRepository {
    /// Find mail_attachment by access_token (excludes soft-deleted)
    pub async fn find_by_access_token(&self, access_token: uuid::Uuid) -> Result<Option<MailAttachment>> {
        self.find_by_uuid_field("access_token", access_token).await
    }

    /// Check if mail_attachment exists by access_token (excludes soft-deleted)
    pub async fn exists_by_access_token(&self, access_token: uuid::Uuid) -> Result<bool> {
        self.exists_by_uuid_field("access_token", access_token).await
    }

}

backbone_core::impl_crud_repository!(MailAttachmentRepository, MailAttachment, soft_delete);