backbone-bucket 0.3.0

Bucket Bounded Context: File Storage Module for Backbone Framework
Documentation
//! Repository for Bucket entities
//!
//! Generated by metaphor-schema. Do not edit manually.
//!
//! Thin newtype over `backbone_orm::GenericCrudRepository<Bucket, backbone_orm::SoftDelete>`.
//! All standard CRUD methods are available via `Deref`.

use anyhow::Result;
use sqlx::PgPool;

use crate::domain::entity::Bucket;

/// Table name for Bucket entities
pub const TABLE_NAME: &str = "bucket.buckets";

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

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

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

impl BucketRepository {
    /// Find bucket by slug (excludes soft-deleted)
    pub async fn find_by_slug(&self, slug: &str) -> Result<Option<Bucket>> {
        self.find_by_text_field("slug", slug).await
    }

    /// Check if bucket exists by slug (excludes soft-deleted)
    pub async fn exists_by_slug(&self, slug: &str) -> Result<bool> {
        self.exists_by_text_field("slug", slug).await
    }

}

backbone_core::impl_crud_repository!(BucketRepository, Bucket, soft_delete);