prorm API Reference
    Preparing search index...

    Class BaseDialectAbstract

    Abstract base class for database dialects Provides common functionality for all dialect implementations

    Hierarchy (View Summary)

    Implements

    Index
    connect disconnect getConnection isConnected query queryStream escape escapeId quoteIdentifier quoteTable getDatabaseVersion createTable dropTable createPartitionedTable createPartition attachPartition detachPartition dropPartition createView dropView createMaterializedView refreshMaterializedView dropMaterializedView hasMaterializedView createStoredProcedure createProcedure dropStoredProcedure dropProcedure executeStoredProcedure hasStoredProcedure createTrigger dropTrigger hasTrigger createSequence dropSequence nextSequenceValue hasSequence createPolicy dropPolicy enableRLS disableRLS hasPolicy commentTable commentColumn createPartialIndex createExpressionIndex createIdentityColumn createComputedColumn addColumn removeColumn changeColumn renameColumn addForeignKey bulkInsert showTables showViews showMaterializedViews showConstraints addConstraint removeConstraint showIndexes describeTable renameTable addIndex removeIndex createIndex createFulltextIndex createSpatialIndex dropIndex createConstraint dropConstraint changeOwner createForeignDataWrapper dropForeignDataWrapper createForeignServer dropForeignServer createForeignTable createSecurityPolicy dropSecurityPolicy startTransaction commitTransaction rollbackTransaction getDataTypeSql buildWhereClause buildOrderClause buildLimitOffset buildInsertQuery buildUpdateQuery buildDeleteQuery buildSelectQuery createSchema dropSchema showAllSchemas listSchemas createDatabaseSQL dropDatabaseSQL createSavepointSQL releaseSavepointSQL rollbackToSavepointSQL createExtension dropExtension getExtensions hasExtension createEnumType dropType createDomain dropDomain buildCreateServerQuery buildAlterServerQuery buildDropServerQuery buildCreateUserMappingQuery buildAlterUserMappingQuery buildDropUserMappingQuery createUserMapping dropUserMapping buildCreateForeignTableQuery buildDropForeignTableQuery buildImportForeignSchemaQuery getServersQuery buildCreateUserQuery buildAlterUserQuery buildDropUserQuery getUsersQuery buildGrantQuery buildRevokeQuery buildShowGrantsQuery buildFlushPrivilegesQuery buildCreateRoleQuery buildDropRoleQuery buildGrantRoleQuery buildRevokeRoleQuery getRolesQuery buildUpsertQuery buildIncrementQuery buildJsonQuery formatValue formatDate replaceReplacements replacePositionalReplacements replaceNamedReplacements escapeReplacement parseValue getIsolationLevelSql resolveAllInclude generateSelectColumns flattenIncludesWithAll
    name: string

    The name of the dialect

    library: string

    The database library or driver being used

    _connection: any = null
    _connected: boolean = false
    dialectName: string = 'unknown'
    • Execute a query and stream the results back as a Node.js Readable (object mode — one row, or one model instance when options.mapToModel is set, per chunk) instead of buffering the whole result set in memory. Used by Model.findAllStream()/findAllIterate() for processing large tables without loading them all into memory at once.

      Native server-side cursor support (postgres/mysql/cockroachdb) is used where the driver has it; other dialects fall back to LIMIT/OFFSET-paged queries — correct and dialect-agnostic, though it does more round trips than a real cursor for very large result sets.

      Parameters

      • sql: string

        The SQL query string to stream results for

      • Optionaloptions: StreamOptions

        Streaming options (batch size, backpressure watermark, model mapping)

      Returns Readable

      const stream = dialect.queryStream('SELECT * FROM users', { batchSize: 500 });
      for await (const row of stream) { console.log(row); }
    • Escape a value for use in a query

      Parameters

      • value: any

        The value to escape

      Returns string

    • Escape an identifier (table name, column name, etc.)

      Parameters

      • identifier: string

        The identifier to escape

      Returns string

    • Quote an identifier (column name, table name)

      Parameters

      • identifier: string

        The identifier to quote

      Returns string

    • Quote a table name

      Parameters

      • tableName: string

        The table name to quote

      • Optionalschema: string

        Optional schema to prefix the table with

      Returns string

    • Create a partitioned table (PostgreSQL 10+)

      Parameters

      • tableName: string
      • columns: Record<string, ColumnDefinition>
      • Optionaloptions: TableOptions & {
            partitionBy: {
                type: "range" | "list" | "hash";
                column: string | string[];
            };
            partitions?: {
                name: string;
                bound?: PartitionBound;
                tablespace?: string;
                storageParameters?: Record<string, string | number>;
            }[];
        }

      Returns Promise<void>

    • Drop a partition (PostgreSQL 10+)

      Parameters

      • partitionName: string
      • Optionaloptions: { ifExists?: boolean; cascade?: boolean }

      Returns Promise<void>

    • Create a database view

      Parameters

      • viewName: string

        Name of the view to create

      • query: string

        The SELECT query for the view

      • Optionaloptions: ViewOptions

        View options

      Returns Promise<void>

    • Refresh a materialized view (PostgreSQL only)

      Parameters

      • viewName: string

        Name of the materialized view to refresh

      • Optionaloptions: RefreshOptions

        Refresh options

      Returns Promise<void>

    • Check if a materialized view exists (PostgreSQL only)

      Parameters

      • viewName: string

        Name of the materialized view

      Returns Promise<boolean>

      True if the materialized view exists

    • Check if a stored procedure exists

      Parameters

      • procedureName: string

        Name of the stored procedure

      • Optionalschema: string

        Schema name (PostgreSQL)

      Returns Promise<boolean>

      True if the stored procedure exists

    • Drop a trigger

      Parameters

      • triggerName: string

        Name of the trigger

      • tableName: string

        Table the trigger is attached to

      • Optionaloptions: DropTriggerOptions

        Drop options

      Returns Promise<void>

    • Check if a trigger exists

      Parameters

      • triggerName: string

        Name of the trigger

      • tableName: string

        Table the trigger is attached to

      Returns Promise<boolean>

      True if the trigger exists

    • Get next value from a sequence (PostgreSQL)

      Parameters

      • sequenceName: string

        Name of the sequence

      Returns Promise<number>

      Next sequence value

    • Check if a sequence exists (PostgreSQL)

      Parameters

      • sequenceName: string

        Name of the sequence

      Returns Promise<boolean>

      True if the sequence exists

    • Drop a policy (PostgreSQL RLS)

      Parameters

      • policyName: string

        Name of the policy

      • tableName: string

        Table name

      • Optionaloptions: DropPolicyOptions

        Drop options

      Returns Promise<void>

    • Enable row-level security on a table (PostgreSQL)

      Parameters

      • tableName: string

        Table name

      • Optionalschema: string

        Schema name

      Returns Promise<void>

    • Disable row-level security on a table (PostgreSQL)

      Parameters

      • tableName: string

        Table name

      • Optionalschema: string

        Schema name

      Returns Promise<void>

    • Check if a policy exists (PostgreSQL RLS)

      Parameters

      • policyName: string

        Name of the policy

      • tableName: string

        Table name

      Returns Promise<boolean>

      True if the policy exists

    • Add comment to a table

      Parameters

      • tableName: string

        Table name

      • comment: string

        Comment text

      Returns Promise<void>

    • Add comment to a column

      Parameters

      • tableName: string

        Table name

      • columnName: string

        Column name

      • comment: string

        Comment text

      Returns Promise<void>

    • Create a partial index (index with WHERE clause)

      Parameters

      • tableName: string

        Table name

      • indexName: string

        Index name

      • fields: string[]

        Fields to index

      • where: string

        WHERE clause for partial index

      • Optionaloptions: IndexOptions

        Additional index options

      Returns Promise<void>

    • Create an expression index

      Parameters

      • tableName: string

        Table name

      • indexName: string

        Index name

      • expression: string

        Expression for the index

      • Optionaloptions: IndexOptions

        Additional index options

      Returns Promise<void>

    • Create an identity column

      Parameters

      • tableName: string

        Table name

      • columnName: string

        Column name

      • Optionaloptions: {
            startWith?: number;
            incrementBy?: number;
            minvalue?: number;
            maxvalue?: number;
            cycle?: boolean;
        }

        Identity options

      Returns Promise<void>

    • Create a computed column

      Parameters

      • tableName: string

        Table name

      • columnName: string

        Column name

      • expression: string

        Expression for computed column

      • Optionaloptions: { persisted?: boolean; type?: string }

        Computed column options

      Returns Promise<void>

    • Add a column to a table

      Parameters

      • tableName: string

        Name of the table

      • columnName: string

        Name of the new column

      • definition: ColumnDefinition

        Column definition

      Returns Promise<void>

    • Remove a column from a table

      Parameters

      • tableName: string

        Name of the table

      • columnName: string

        Name of the column to remove

      Returns Promise<void>

    • Change a column definition

      Parameters

      • tableName: string

        Name of the table

      • columnName: string

        Name of the column to change

      • definition: ColumnDefinition

        New column definition

      Returns Promise<void>

    • Rename a column (default throws error)

      Parameters

      • _tableName: string
      • _oldColumnName: string
      • _newColumnName: string

      Returns Promise<void>

    • Add a foreign key (default throws error)

      Parameters

      • _tableName: string
      • _columnName: string
      • _referencedTableName: string
      • _referencedColumnName: string
      • Optional_options: any

      Returns Promise<void>

    • Bulk insert records (default implementation)

      Parameters

      • tableName: string
      • records: Record<string, any>[]
      • Optional_options: any

      Returns Promise<QueryResult>

    • Add a constraint to a table

      Parameters

      • tableName: string
      • options: {
            type: "UNIQUE" | "PRIMARY KEY" | "FOREIGN KEY" | "CHECK";
            fields: string[];
            name?: string;
            references?: { table: string; fields: string[] };
            check?: string;
        }

      Returns Promise<void>

    • Remove a constraint from a table

      Parameters

      • tableName: string
      • constraintName: string

      Returns Promise<void>

    • Rename a table

      Parameters

      • oldName: string

        Current table name

      • newName: string

        New table name

      Returns Promise<void>

    • Add an index to a table

      Parameters

      • tableName: string

        Name of the table

      • indexName: string

        Name of the index

      • fields: string[]

        Fields to index

      • Optionaloptions: IndexOptions

        Index options

      Returns Promise<void>

    • Remove an index from a table

      Parameters

      • tableName: string

        Name of the table

      • indexName: string

        Name of the index

      Returns Promise<void>

    • Create a fulltext index (default throws error)

      Parameters

      • _tableName: string
      • _indexName: string
      • _fields: string[]
      • Optional_options: { parser?: string; comment?: string }

      Returns Promise<void>

    • Create a spatial index (default throws error)

      Parameters

      • _tableName: string
      • _indexName: string
      • _fields: string[]
      • Optional_options: { storage?: string; srid?: number }

      Returns Promise<void>

    • Drop an index from a table

      Parameters

      • tableName: string

        Name of the table

      • indexName: string

        Name of the index

      • Optionaloptions: DropIndexOptions

        Drop options

      Returns Promise<void>

    • Change owner of a table or view

      Parameters

      • newOwner: string
      • tableName: string

      Returns Promise<void>

    • Create a foreign data wrapper (PostgreSQL)

      Parameters

      • fdwName: string
      • Optionaloptions: { handler?: string }

      Returns Promise<void>

    • Drop a foreign data wrapper (PostgreSQL)

      Parameters

      • fdwName: string
      • Optionaloptions: { ifExists?: boolean }

      Returns Promise<void>

    • Create a foreign server (PostgreSQL)

      Parameters

      • serverName: string
      • fdwName: string
      • Optionaloptions: { options?: Record<string, string>; ifNotExists?: boolean }

      Returns Promise<void>

    • Drop a foreign server (PostgreSQL)

      Parameters

      • serverName: string
      • Optionaloptions: { ifExists?: boolean; cascade?: boolean }

      Returns Promise<void>

    • Create a foreign table (PostgreSQL)

      Parameters

      • tableName: string
      • columns: Record<string, { type: string }>
      • Optionaloptions: { serverName?: string; ifNotExists?: boolean }

      Returns Promise<void>

    • Create a security policy (MSSQL Row-Level Security)

      Parameters

      • policyName: string
      • tableName: string
      • Optionaloptions: { predicate?: string }

      Returns Promise<void>

    • Drop a security policy (MSSQL Row-Level Security)

      Parameters

      • policyName: string
      • tableName: string

      Returns Promise<void>

    • Build a LIMIT/OFFSET clause

      Parameters

      • Optionallimit: string | number

        Limit value

      • Optionaloffset: string | number

        Offset value

      Returns string

    • Build an INSERT query

      Parameters

      • tableName: string

        Table name

      • values: Record<string, any>

        Values to insert

      • Optionaloptions: InsertOptions

        Query options

      Returns { sql: string; values: any[] }

    • Generate SQL for creating a database (default implementation)

      Parameters

      • options: {
            name: string;
            encoding?: string;
            lcCollate?: string;
            lcCtype?: string;
            template?: string;
            tablespace?: string;
            collate?: string;
            isTemplate?: boolean;
        }

        Database creation options

      Returns string

    • Generate SQL for creating a savepoint

      Parameters

      • Optionalname: string

        Savepoint name (optional, will be generated if not provided)

      Returns string

    • Check if a PostgreSQL extension is installed (only supported in PostgreSQL)

      Parameters

      • _extensionName: string

      Returns Promise<boolean>

      True if the extension is installed

    • Create a PostgreSQL domain (only supported in PostgreSQL)

      Parameters

      Returns Promise<void>

    • Parameters

      • _name: string
      • Optional_opts: { ifExists?: boolean; cascade?: boolean }

      Returns string

    • Parameters

      • _serverName: string
      • _user: string
      • Optional_opts: { ifExists?: boolean }

      Returns string

    • Create a user mapping (default throws error)

      Parameters

      • _userName: string
      • _serverName: string
      • Optional_options: any

      Returns Promise<void>

    • Drop a user mapping (default throws error)

      Parameters

      • _userName: string
      • _serverName: string
      • Optional_options: any

      Returns Promise<void>

    • Parameters

      • _tableName: string
      • Optional_opts: { ifExists?: boolean; cascade?: boolean }

      Returns string

    • Build an UPSERT query (insert or update on conflict)

      Parameters

      • tableName: string

        Table name

      • values: Record<string, any>

        Values to insert/update

      • Optionaloptions: UpsertQueryOptions

        Upsert options

      Returns { sql: string; values: any[] }

    • Build an UPSERT query (insert or update on conflict)

      Parameters

      • tableName: string

        Table name

      • values: Record<string, any>

        Values to insert/update

      • Optionaloptions: UpsertQueryOptions

        Upsert options

      Returns { sql: string; values: any[] }

    • Build an increment query

      Parameters

      • tableName: string

        Table name

      • fields: string | string[] | Record<string, number>

        Fields to increment

      • where: WhereOptions

        Where clause

      • Optionaloptions: { by?: number }

        Query options (by: number)

      Returns { sql: string; values: any[] }

    • Build a JSON/JSONB path query Default implementation using common JSON extraction syntax

      Parameters

      • column: string

        The JSON/JSONB column name

      • path: string

        The JSON path to access (e.g., 'key' or 'key.subkey')

      • Optionalvalue: unknown

        The value to compare against (optional)

      • operator: string = '='

        The comparison operator to use (defaults to =)

      Returns { sql: string; values: unknown[] }

      SQL fragment and values for the JSON query

    • Format a value for SQL based on its type

      Parameters

      • value: any

      Returns string

    • Format a date for SQL

      Parameters

      • date: Date

      Returns string

    • Replace placeholders in SQL with actual values Supports both named (:param) and positional (?) placeholders Properly escapes values to prevent SQL injection

      Parameters

      • sql: string
      • Optionalreplacements: unknown[] | Record<string, unknown>

      Returns string

    • Replace positional (?) placeholders with escaped values

      Parameters

      • sql: string
      • replacements: unknown[]

      Returns string

    • Replace named (:param) placeholders with escaped values

      Parameters

      • sql: string
      • replacements: Record<string, unknown>

      Returns string

    • Escape a replacement value for safe inclusion in SQL

      Parameters

      • value: unknown

      Returns string

    • Get the isolation level SQL

      Parameters

      • OptionalisolationLevel: string

      Returns string

    • Generate column list with proper aliasing to avoid duplicates

      Parameters

      • mainTableName: string
      • mainTableAlias: string
      • Optionalattributes: string[] | { include?: string[]; exclude?: string[] }
      • Optionalincludes: { tableName: string; alias: string }[]

      Returns string