Skip to main content
Version: 7.0

abstractPlatform

Abstract base class providing database-specific behavior and SQL dialect differences.

Hierarchy

Index

Constructors

Methods

Constructors

constructor

Methods

allowsComparingTuples

  • allowsComparingTuples(): boolean
  • Whether the platform supports tuple comparison in WHERE clauses.


    Returns boolean

cloneEmbeddable

  • cloneEmbeddable<T>(data): T
  • Deep-clones embeddable data and tags it for JSON serialization.


    Parameters

    • data: T

    Returns T

compareUuids

  • compareUuids(): string
  • Determines how UUID values are compared in the change set tracking. Return 'string' for inline string comparison (fast), or 'any' for deep comparison via type methods.


    Returns string

convertDateToJSValue

  • convertDateToJSValue(value): string
  • Parameters

    • value: string | Date

    Returns string

convertIntervalToDatabaseValue

  • convertIntervalToDatabaseValue(value): unknown
  • Parameters

    • value: unknown

    Returns unknown

convertIntervalToJSValue

  • convertIntervalToJSValue(value): unknown
  • Parameters

    • value: string

    Returns unknown

convertJsonToDatabaseValue

  • convertJsonToDatabaseValue(value, context): unknown
  • Converts a JS value to its JSON database representation (typically JSON.stringify).


    Parameters

    Returns unknown

convertJsonToJSValue

  • convertJsonToJSValue(value, context): unknown
  • Converts a database JSON value to its JS representation.


    Parameters

    Returns unknown

convertsJsonAutomatically

  • convertsJsonAutomatically(): boolean
  • Whether the driver automatically parses JSON columns into JS objects.


    Returns boolean

convertUuidToDatabaseValue

  • convertUuidToDatabaseValue(value): unknown
  • Parameters

    • value: unknown

    Returns unknown

convertUuidToJSValue

  • convertUuidToJSValue(value): unknown
  • Parameters

    • value: unknown

    Returns unknown

convertVersionValue

  • convertVersionValue(value, prop): string | number | Date | { $in: (string | number)[] }
  • Converts a version field value for comparison in optimistic locking queries.


    Parameters

    Returns string | number | Date | { $in: (string | number)[] }

denormalizePrimaryKey

  • denormalizePrimaryKey(data): IPrimaryKeyValue
  • Converts scalar primary key representation to native driver wrapper (e.g. string to mongodb's ObjectId)


    Parameters

    • data: IPrimaryKeyValue

    Returns IPrimaryKeyValue

escape

  • escape(value): string
  • Parameters

    • value: any

    Returns string

extractSimpleType

  • extractSimpleType(type): string
  • Extracts the base type name from a full SQL type declaration (e.g. "varchar(255)" -> "varchar").


    Parameters

    • type: string

    Returns string

formatQuery

  • formatQuery(sql, params): string
  • Replaces ? placeholders in SQL with quoted parameter values.


    Parameters

    • sql: string
    • params: readonly any[]

    Returns string

generateCustomOrder

  • generateCustomOrder(escapedColumn, values): void
  • Generates a custom order by statement given a set of in order values, eg. ORDER BY (CASE WHEN priority = 'low' THEN 1 WHEN priority = 'medium' THEN 2 ELSE NULL END)


    Parameters

    • escapedColumn: string
    • values: unknown[]

    Returns void

getArrayDeclarationSQL

  • getArrayDeclarationSQL(): string
  • Returns the SQL type declaration used for array storage.


    Returns string

getBigIntTypeDeclarationSQL

  • getBigIntTypeDeclarationSQL(column): string
  • Parameters

    • column: { autoincrement?: boolean; length?: number; unsigned?: boolean }
      • optionalautoincrement: boolean
      • optionallength: number
      • optionalunsigned: boolean

    Returns string

getBlobDeclarationSQL

  • getBlobDeclarationSQL(): string
  • Returns string

getBooleanTypeDeclarationSQL

  • getBooleanTypeDeclarationSQL(): string
  • Returns the SQL type declaration for boolean columns.


    Returns string

getCharTypeDeclarationSQL

  • getCharTypeDeclarationSQL(column): string
  • Parameters

    • column: { length?: number }
      • optionallength: number

    Returns string

getConfig

getCurrentTimestampSQL

  • getCurrentTimestampSQL(length): string
  • Returns the SQL specific for the platform to get the current timestamp


    Parameters

    • optionallength: number

    Returns string

getDateTimeTypeDeclarationSQL

  • getDateTimeTypeDeclarationSQL(column): string
  • Returns the SQL type declaration for datetime columns.


    Parameters

    • column: { length?: number }
      • optionallength: number

    Returns string

getDateTypeDeclarationSQL

  • getDateTypeDeclarationSQL(length): string
  • Returns the SQL type declaration for date columns.


    Parameters

    • optionallength: number

    Returns string

getDecimalTypeDeclarationSQL

  • getDecimalTypeDeclarationSQL(column): string
  • Parameters

    • column: { precision?: number; scale?: number }
      • optionalprecision: number
      • optionalscale: number

    Returns string

getDefaultCharLength

  • getDefaultCharLength(): number
  • Returns the default length for char columns.


    Returns number

getDefaultCharset

  • getDefaultCharset(): string
  • Returns the default character set for this platform.


    Returns string

getDefaultClientUrl

  • getDefaultClientUrl(): string
  • Returns default client url for given driver (e.g. mongodb://127.0.0.1:27017 for mongodb)


    Returns string

getDefaultDateTimeLength

  • getDefaultDateTimeLength(): number
  • Returns the default fractional seconds precision for datetime columns.


    Returns number

getDefaultMappedType

  • getDefaultMappedType(type): Type<unknown, unknown>
  • Returns the default mapped Type for a given type string when no custom mapping is configured.


    Parameters

    • type: string

    Returns Type<unknown, unknown>

getDefaultPrimaryName

  • getDefaultPrimaryName(tableName, columns): string
  • Returns the default primary key constraint name.


    Parameters

    • tableName: string
    • columns: string[]

    Returns string

getDefaultSchemaName

  • getDefaultSchemaName(): undefined | string
  • Returns the default schema name for this platform (e.g. "public" for PostgreSQL).


    Returns undefined | string

getDefaultVarcharLength

  • getDefaultVarcharLength(): number
  • Returns the default length for varchar columns.


    Returns number

getDefaultVersionLength

  • getDefaultVersionLength(): number
  • Returns the default fractional seconds precision for version timestamp columns.


    Returns number

getDoubleDeclarationSQL

  • getDoubleDeclarationSQL(): string
  • Returns string

getEnumTypeDeclarationSQL

  • getEnumTypeDeclarationSQL(column): string
  • Parameters

    • column: { autoincrement?: boolean; fieldNames: string[]; items?: unknown[]; length?: number; unsigned?: boolean }
      • optionalautoincrement: boolean
      • fieldNames: string[]
      • optionalitems: unknown[]
      • optionallength: number
      • optionalunsigned: boolean

    Returns string

getExceptionConverter

  • Returns the exception converter for translating native errors to driver exceptions.


    Returns ExceptionConverter

getExtension

  • getExtension<T>(extensionName, extensionKey, moduleName, em): T
  • Retrieves a registered extension (e.g. SchemaGenerator, Migrator), throwing if not found.


    Parameters

    Returns T

getFloatDeclarationSQL

  • getFloatDeclarationSQL(): string
  • Returns string

getFullTextIndexExpression

  • getFullTextIndexExpression(indexName, schemaName, tableName, columns): string
  • Parameters

    • indexName: string
    • schemaName: undefined | string
    • tableName: string
    • columns: SimpleColumnMeta[]

    Returns string

getFullTextWhereClause

  • getFullTextWhereClause(prop): string

getIndexName

  • getIndexName(tableName, columns, type): string
  • Returns the default name of index for the given columns


    Parameters

    • tableName: string
    • columns: string[]
    • type: primary | index | unique | foreign | sequence

    Returns string

getIntegerTypeDeclarationSQL

  • getIntegerTypeDeclarationSQL(column): string
  • Returns the SQL type declaration for integer columns.


    Parameters

    • column: { autoincrement?: boolean; length?: number; unsigned?: boolean }
      • optionalautoincrement: boolean
      • optionallength: number
      • optionalunsigned: boolean

    Returns string

getIntervalTypeDeclarationSQL

  • getIntervalTypeDeclarationSQL(column): string
  • Parameters

    • column: { length?: number }
      • optionallength: number

    Returns string

getJsonDeclarationSQL

  • getJsonDeclarationSQL(): string
  • Returns string

getJsonIndexDefinition

  • getJsonIndexDefinition(index): string[]
  • Parameters

    • index: { columnNames: string[] }
      • columnNames: string[]

    Returns string[]

getMappedType

  • getMappedType(type): Type<unknown, unknown>
  • Returns the mapped Type instance for a given SQL/runtime type string.


    Parameters

    • type: string

    Returns Type<unknown, unknown>

getMediumIntTypeDeclarationSQL

  • getMediumIntTypeDeclarationSQL(column): string
  • Parameters

    • column: { autoincrement?: boolean; length?: number; unsigned?: boolean }
      • optionalautoincrement: boolean
      • optionallength: number
      • optionalunsigned: boolean

    Returns string

getNamingStrategy

getRegExpOperator

  • getRegExpOperator(val, flags): string
  • Returns the SQL operator used for regular expression matching.


    Parameters

    • optionalval: unknown
    • optionalflags: string

    Returns string

getRegExpValue

  • getRegExpValue(val): { $flags?: string; $re: string }
  • Converts a JavaScript RegExp into a platform-specific regex representation.


    Parameters

    • val: RegExp

    Returns { $flags?: string; $re: string }

    • optional$flags?: string
    • $re: string

getRepositoryClass

getSchemaGenerator

getSchemaHelper

  • getSchemaHelper(): unknown
  • Returns the schema helper instance for this platform, or undefined if not supported.


    Returns unknown

getSearchJsonPropertyKey

  • getSearchJsonPropertyKey(path, type, aliased, value): string | RawQueryFragment<string>
  • Parameters

    • path: string[]
    • type: string
    • aliased: boolean
    • optionalvalue: unknown

    Returns string | RawQueryFragment<string>

getSearchJsonPropertySQL

  • getSearchJsonPropertySQL(path, type, aliased): string | RawQueryFragment<string>
  • Parameters

    • path: string
    • type: string
    • aliased: boolean

    Returns string | RawQueryFragment<string>

getSmallIntTypeDeclarationSQL

  • getSmallIntTypeDeclarationSQL(column): string
  • Parameters

    • column: { autoincrement?: boolean; length?: number; unsigned?: boolean }
      • optionalautoincrement: boolean
      • optionallength: number
      • optionalunsigned: boolean

    Returns string

getTextTypeDeclarationSQL

  • getTextTypeDeclarationSQL(_column): string
  • Parameters

    • _column: { length?: number }
      • optionallength: number

    Returns string

getTimeTypeDeclarationSQL

  • getTimeTypeDeclarationSQL(length): string
  • Returns the SQL type declaration for time columns.


    Parameters

    • optionallength: number

    Returns string

getTimezone

  • getTimezone(): undefined | string
  • Returns the configured timezone, or undefined if not set.


    Returns undefined | string

getTinyIntTypeDeclarationSQL

  • getTinyIntTypeDeclarationSQL(column): string
  • Parameters

    • column: { autoincrement?: boolean; length?: number; unsigned?: boolean }
      • optionalautoincrement: boolean
      • optionallength: number
      • optionalunsigned: boolean

    Returns string

getUuidTypeDeclarationSQL

  • getUuidTypeDeclarationSQL(column): string
  • Parameters

    • column: { length?: number }
      • optionallength: number

    Returns string

getVarcharTypeDeclarationSQL

  • getVarcharTypeDeclarationSQL(column): string
  • Parameters

    • column: { length?: number }
      • optionallength: number

    Returns string

indexForeignKeys

  • indexForeignKeys(): boolean
  • Whether the platform automatically creates indexes on foreign key columns.


    Returns boolean

isAllowedTopLevelOperator

  • isAllowedTopLevelOperator(operator): boolean
  • Whether the given operator is allowed at the top level of a query condition.


    Parameters

    • operator: string

    Returns boolean

isBigIntProperty

  • isBigIntProperty(prop): boolean
  • Whether the given property maps to a bigint database column.


    Parameters

    Returns boolean

isNumericColumn

  • isNumericColumn(mappedType): boolean
  • Whether the given mapped type represents a numeric column.


    Parameters

    • mappedType: Type<unknown, unknown>

    Returns boolean

isNumericProperty

  • isNumericProperty(prop, ignoreCustomType): boolean
  • Whether the given property represents a numeric database column.


    Parameters

    Returns boolean

isPopulated

  • isPopulated<T>(key, populate): boolean
  • Whether the given property key is included in the populate hint.


    Parameters

    Returns boolean

lookupExtensions

  • lookupExtensions(orm): void

mapRegExpCondition

  • mapRegExpCondition(mappedKey, value): { params: unknown[]; sql: string }
  • Builds the SQL clause and parameters for a regular expression condition.


    Parameters

    • mappedKey: string
    • value: { $flags?: string; $re: string }
      • optional$flags: string
      • $re: string

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

    • params: unknown[]
    • sql: string

marshallArray

  • marshallArray(values): string
  • Serializes a string array into its database storage format.


    Parameters

    • values: string[]

    Returns string

normalizeColumnType

  • normalizeColumnType(type, options): string
  • This should be used only to compare types, it can strip some information like the length.


    Parameters

    • type: string
    • options: { length?: number; precision?: number; scale?: number }
      • optionallength: number
      • optionalprecision: number
      • optionalscale: number

    Returns string

normalizePrimaryKey

  • normalizePrimaryKey<T>(data): T
  • Normalizes primary key wrapper to scalar value (e.g. mongodb's ObjectId to string)


    Parameters

    • data: IPrimaryKeyValue | Primary<T>

    Returns T

parseDate

  • parseDate(value): Date
  • Parses a string or numeric value into a Date object.


    Parameters

    • value: string | number

    Returns Date

processDateProperty

  • processDateProperty(value): string | number | Date
  • Processes a date value before persisting, applying timezone or format conversions.


    Parameters

    • value: unknown

    Returns string | number | Date

processJsonCondition

  • processJsonCondition<T>(o, value, path, alias): FilterQuery<T>

quoteIdentifier

  • quoteIdentifier(id, quote): string
  • Wraps a table or column identifier with the platform-specific quote character.


    Parameters

    • id: string | { toString: () => string }
      • toString: () => string
    • quote: string = '`'

    Returns string

quoteValue

  • quoteValue(value): string
  • Quotes a literal value for safe embedding in SQL.


    Parameters

    • value: any

    Returns string

setConfig

  • setConfig(config): void

shouldHaveColumn

  • shouldHaveColumn<T>(prop, populate, exclude, includeFormulas, ignoreInlineEmbeddables): boolean
  • Whether the given property should be included as a column in the SELECT query.


    Parameters

    • prop: EntityProperty<T, any>
    • populate: boolean | readonly PopulateOptions<T>[]
    • optionalexclude: string[]
    • includeFormulas: boolean = true
    • ignoreInlineEmbeddables: boolean = true

    Returns boolean

supportsCreatingFullTextIndex

  • supportsCreatingFullTextIndex(): boolean
  • Returns boolean

supportsCustomPrimaryKeyNames

  • supportsCustomPrimaryKeyNames(): boolean
  • Whether the platform supports custom names for primary key constraints.


    Returns boolean

supportsDeferredUniqueConstraints

  • supportsDeferredUniqueConstraints(): boolean
  • Whether the platform supports deferred unique constraints.


    Returns boolean

supportsDownMigrations

  • supportsDownMigrations(): boolean
  • Whether the platform supports generating down migrations.


    Returns boolean

supportsMaterializedViews

  • supportsMaterializedViews(): boolean
  • Whether this platform supports materialized views.


    Returns boolean

supportsMultipleCascadePaths

  • supportsMultipleCascadePaths(): boolean
  • Whether the platform supports multiple cascade paths to the same table.


    Returns boolean

supportsMultipleStatements

  • supportsMultipleStatements(): boolean
  • Whether the connection supports executing multiple SQL statements in a single call.


    Returns boolean

supportsNativeEnums

  • supportsNativeEnums(): boolean
  • for postgres native enums


    Returns boolean

supportsOnUpdate

  • supportsOnUpdate(): boolean
  • Returns true if the platform supports ON UPDATE foreign key rules. Oracle doesn't support ON UPDATE rules.


    Returns boolean

supportsTransactions

  • supportsTransactions(): boolean
  • Whether this driver supports database transactions.


    Returns boolean

supportsUnionWhere

  • supportsUnionWhere(): boolean
  • Whether the platform supports the UNION WHERE optimization for multi-branch queries.


    Returns boolean

supportsUnsigned

  • supportsUnsigned(): boolean
  • Whether the platform supports unsigned integer columns.


    Returns boolean

unmarshallArray

  • unmarshallArray(value): string[]
  • Deserializes a database-stored array string back into a string array.


    Parameters

    • value: string

    Returns string[]

usesAsKeyword

  • usesAsKeyword(): boolean
  • Returns boolean

usesBatchInserts

  • usesBatchInserts(): boolean
  • Whether or not the driver supports retuning list of created PKs back when multi-inserting


    Returns boolean

usesBatchUpdates

  • usesBatchUpdates(): boolean
  • Whether or not the driver supports updating many records at once


    Returns boolean

usesCascadeStatement

  • usesCascadeStatement(): boolean
  • Whether DELETE statements require explicit CASCADE keyword.


    Returns boolean

usesDefaultKeyword

  • usesDefaultKeyword(): boolean
  • Whether the platform supports the DEFAULT keyword in INSERT statements.


    Returns boolean

usesEnumCheckConstraints

  • usesEnumCheckConstraints(): boolean
  • for postgres text enums (default)


    Returns boolean

usesImplicitTransactions

  • usesImplicitTransactions(): boolean
  • Whether the driver wraps operations in implicit transactions by default.


    Returns boolean

usesOutputStatement

  • usesOutputStatement(): boolean
  • Whether the driver supports OUTPUT clause (e.g. MSSQL).


    Returns boolean

usesPivotTable

  • usesPivotTable(): boolean
  • Whether this driver uses pivot tables for M:N relations (SQL drivers do, MongoDB does not).


    Returns boolean

usesReturningStatement

  • usesReturningStatement(): boolean
  • Whether the driver supports RETURNING clause (e.g. PostgreSQL).


    Returns boolean

validateMetadata

  • validateMetadata(meta): void
Page Options