Skip to main content

backbone_bucket/infrastructure/persistence/
file_lock_repository.rs

1//! Repository for FileLock entities
2//!
3//! Generated by metaphor-schema. Do not edit manually.
4//!
5//! Thin newtype over `backbone_orm::GenericCrudRepository<FileLock, backbone_orm::SoftDelete>`.
6//! All standard CRUD methods are available via `Deref`.
7
8use anyhow::Result;
9use sqlx::PgPool;
10use uuid::Uuid;
11
12use crate::domain::entity::FileLock;
13
14/// Table name for FileLock entities
15pub const TABLE_NAME: &str = "bucket.file_locks";
16
17/// Repository for FileLock entities.
18///
19/// All standard CRUD, soft-delete, pagination, and bulk methods are
20/// provided automatically via `Deref` to `backbone_orm::GenericCrudRepository`.
21pub struct FileLockRepository(
22    backbone_orm::GenericCrudRepository<FileLock, backbone_orm::SoftDelete>,
23);
24
25impl std::ops::Deref for FileLockRepository {
26    type Target = backbone_orm::GenericCrudRepository<FileLock, backbone_orm::SoftDelete>;
27    fn deref(&self) -> &Self::Target { &self.0 }
28}
29
30impl FileLockRepository {
31    /// Create a new repository instance.
32    pub fn new(pool: PgPool) -> Self {
33        Self(backbone_orm::GenericCrudRepository::new(pool, TABLE_NAME))
34    }
35}
36
37impl FileLockRepository {
38    /// Find file_lock by file_id (excludes soft-deleted)
39    pub async fn find_by_file_id(&self, file_id: uuid::Uuid) -> Result<Option<FileLock>> {
40        self.find_by_uuid_field("file_id", file_id).await
41    }
42
43    /// Check if file_lock exists by file_id (excludes soft-deleted)
44    pub async fn exists_by_file_id(&self, file_id: uuid::Uuid) -> Result<bool> {
45        self.exists_by_uuid_field("file_id", file_id).await
46    }
47
48}
49
50backbone_core::impl_crud_repository!(FileLockRepository, FileLock, soft_delete);