//! Per-entity CRUD implementations for `PostgreSQL`.
//!
//! Each entity type has its own submodule with typed query methods.
//! Queries use `sqlx::query_as!` for compile-time SQL verification
//! against the live database schema.

/// Annotation (label) ingest.
mod annotation;
/// Audio specification CRUD.
mod audio_specification;
/// Beamgram specification CRUD.
mod beamgram_specification;
/// Bearing-time-record specification CRUD.
mod bearing_time_record_specification;
/// Time-series data row operations.
mod data_row;
/// Data stream CRUD.
mod data_stream;
/// Directional spectrogram specification CRUD.
mod directional_spectrogram_specification;
/// Time-series metadata row operations.
mod metadata_row;
/// Mission CRUD.
mod mission;
/// Mission–platform junction CRUD.
mod mission_platform;
/// Ontology CRUD.
mod ontology;
/// Ontology class CRUD.
mod ontology_class;
/// Platform CRUD.
mod platform;
/// Platform information CRUD.
mod platform_information;
/// Platform kind CRUD.
mod platform_kind;
/// Platform–specification junction table operations.
mod platform_specification;
/// Spectrogram specification CRUD.
mod spectrogram_specification;

use sqlx::PgPool;
use uuid::Uuid;

/// Shared repository state for all `PostgreSQL` CRUD operations.
///
/// A single `PostgresRepository` instance provides typed methods for every
/// entity type. The connection pool and organization ID are shared across
/// all operations.
#[derive(Debug, Clone)]
pub struct PostgresRepository {
    /// Scoping organization for RLS. `None` uses the entity's own org.
    organization_id: Option<Uuid>,
    /// Connection pool shared across all operations.
    pool: PgPool,
}

impl PostgresRepository {
    /// Create a new repository backed by the given connection pool.
    #[must_use]
    pub const fn new(pool: PgPool, organization_id: Option<Uuid>) -> Self {
        Self {
            organization_id,
            pool,
        }
    }
}
