Main Data Access Layer class for PostgreSQL

Provides connection management, transaction support, and model creation functionality. This class serves as the main interface between the application and the PostgreSQL database.

Implements

Constructors

Properties

config: DataAccessLayerConfig
mlString: MlStringVariants = mlString
modelRegistry: ModelRegistry
pool: Pool
revision: RevisionHelpers = revision
schemaNamespace?: string
types: {
    any: (options?: Record<string, unknown>) => Type<unknown, false>;
    array: <TElementField extends SchemaFieldLike = Type<unknown, false>>(
        elementType?: TElementField,
        options?: Record<string, unknown>,
    ) => ArrayType<TElementField, false>;
    boolean: (options?: Record<string, unknown>) => BooleanType<false>;
    date: (options?: Record<string, unknown>) => DateType<false>;
    number: (options?: Record<string, unknown>) => NumberType<false>;
    object: (options?: Record<string, unknown>) => ObjectType<unknown, false>;
    string: (options?: Record<string, unknown>) => StringType<false>;
    virtual: <TValue = unknown>(
        options?: Record<string, unknown>,
    ) => VirtualType<TValue, false>;
} = types

Methods

  • Get a connection from the pool

    Returns Promise<PoolClient>

    PostgreSQL client connection

  • Get pool statistics

    Returns { idleCount: number; totalCount: number; waitingCount: number }

  • Execute a transaction with automatic rollback on error

    Type Parameters

    • T

    Parameters

    • callback: (client: PoolClient) => Promise<T>

      Function to execute within transaction

    Returns Promise<T>

    Result of the callback function