backbone-bucket 0.3.0

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

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

use crate::domain::entity::FileLock;

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

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

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

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

impl FileLockRepository {
    /// Find file_lock by file_id (excludes soft-deleted)
    pub async fn find_by_file_id(&self, file_id: uuid::Uuid) -> Result<Option<FileLock>> {
        self.find_by_uuid_field("file_id", file_id).await
    }

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

}

backbone_core::impl_crud_repository!(FileLockRepository, FileLock, soft_delete);