Options
All
  • Public
  • Public/Protected
  • All
Menu

Class PostgresDriver

Organizes communication with PostgreSQL DBMS.

Hierarchy

  • PostgresDriver

Implements

Index

Constructors

constructor

Properties

connectedQueryRunners

connectedQueryRunners: QueryRunner[] = []

We store all created query runners because we need to release them.

connection

connection: Connection

Connection used by driver.

Optional database

database: string

Master database used to perform all write queries.

isReplicated

isReplicated: boolean = false

Indicates if replication is enabled.

master

master: any

Pool for master database.

maxAliasLength

maxAliasLength: number = 63

options

Connection options.

postgres

postgres: any

Postgres underlying library.

slaves

slaves: any[] = []

Pool for slave databases. Used in replication.

spatialTypes

spatialTypes: ColumnType[] = ["geometry","geography"]

Gets list of spatial column data types.

supportedDataTypes

supportedDataTypes: ColumnType[] = ["int","int2","int4","int8","smallint","integer","bigint","decimal","numeric","real","float","float4","float8","double precision","money","character varying","varchar","character","char","text","citext","hstore","bytea","bit","varbit","bit varying","timetz","timestamptz","timestamp","timestamp without time zone","timestamp with time zone","date","time","time without time zone","time with time zone","interval","bool","boolean","enum","point","line","lseg","box","path","polygon","circle","cidr","inet","macaddr","tsvector","tsquery","uuid","xml","json","jsonb","int4range","int8range","numrange","tsrange","tstzrange","daterange","geometry","geography"]

treeSupport

treeSupport: boolean = true

Indicates if tree tables are supported by this driver.

withLengthColumnTypes

withLengthColumnTypes: ColumnType[] = ["character varying","varchar","character","char","bit","varbit","bit varying"]

Gets list of column data types that support length by a driver.

withPrecisionColumnTypes

withPrecisionColumnTypes: ColumnType[] = ["numeric","decimal","interval","time without time zone","time with time zone","timestamp without time zone","timestamp with time zone"]

Gets list of column data types that support precision by a driver.

withScaleColumnTypes

withScaleColumnTypes: ColumnType[] = ["numeric","decimal"]

Gets list of column data types that support scale by a driver.

Accessors

uuidGenerator

  • get uuidGenerator(): string

Methods

afterConnect

  • afterConnect(): Promise<void>

buildTableName

  • buildTableName(tableName: string, schema?: string): string
  • Build full table name with schema name and table name. E.g. "mySchema"."myTable"

    Parameters

    • tableName: string
    • Optional schema: string

    Returns string

Protected closePool

  • closePool(pool: any): Promise<void>

connect

  • connect(): Promise<void>
  • Performs connection to the database. Based on pooling options, it can either create connection immediately, either create a pool and create connection when needed.

    Returns Promise<void>

createFullType

createGeneratedMap

createParameter

  • createParameter(parameterName: string, index: number): string

Protected createPool

createQueryRunner

createSchemaBuilder

disconnect

  • disconnect(): Promise<void>

escape

  • escape(columnName: string): string

escapeQueryWithParameters

Protected executeQuery

  • executeQuery(connection: any, query: string): any

findChangedColumns

getColumnLength

isReturningSqlSupported

  • isReturningSqlSupported(): boolean

isUUIDGenerationSupported

  • isUUIDGenerationSupported(): boolean

Protected loadDependencies

  • loadDependencies(): void

loadStreamDependency

  • loadStreamDependency(): any

Private lowerDefaultValueIfNecessary

  • lowerDefaultValueIfNecessary(value: string | undefined): string

normalizeDefault

normalizeIsUnique

normalizeType

  • normalizeType(column: object): string
  • Creates a database type from a given column metadata.

    Parameters

    • column: object
      • Optional isArray?: boolean
      • Optional length?: number | string
      • Optional precision?: number | null
      • Optional scale?: number
      • Optional type?: ColumnType

    Returns string

obtainMasterConnection

  • obtainMasterConnection(): Promise<any>

obtainSlaveConnection

  • obtainSlaveConnection(): Promise<any>

prepareHydratedValue

  • prepareHydratedValue(value: any, columnMetadata: ColumnMetadata): any

preparePersistentValue

  • preparePersistentValue(value: any, columnMetadata: ColumnMetadata): any

Object literals

dataTypeDefaults

dataTypeDefaults: object

Default values of length, precision and scale depends on column data type. Used in the cases when length/precision/scale is not specified by user.

bit

bit: object

length

length: number = 1

character

character: object

length

length: number = 1

interval

interval: object

precision

precision: number = 6

time with time zone

time with time zone: object

precision

precision: number = 6

time without time zone

time without time zone: object

precision

precision: number = 6

timestamp with time zone

timestamp with time zone: object

precision

precision: number = 6

timestamp without time zone

timestamp without time zone: object

precision

precision: number = 6

mappedDataTypes

mappedDataTypes: object

Orm has special columns and we need to know what database column types should be for those types. Column types are driver dependant.

cacheDuration

cacheDuration: "int4" = "int4"

cacheId

cacheId: "int4" = "int4"

cacheIdentifier

cacheIdentifier: "varchar" = "varchar"

cacheQuery

cacheQuery: "text" = "text"

cacheResult

cacheResult: "text" = "text"

cacheTime

cacheTime: "int8" = "int8"

createDate

createDate: "timestamp" = "timestamp"

createDateDefault

createDateDefault: string = "now()"

metadataDatabase

metadataDatabase: "varchar" = "varchar"

metadataName

metadataName: "varchar" = "varchar"

metadataSchema

metadataSchema: "varchar" = "varchar"

metadataTable

metadataTable: "varchar" = "varchar"

metadataType

metadataType: "varchar" = "varchar"

metadataValue

metadataValue: "text" = "text"

migrationId

migrationId: "int4" = "int4"

migrationName

migrationName: "varchar" = "varchar"

migrationTimestamp

migrationTimestamp: "int8" = "int8"

treeLevel

treeLevel: "int4" = "int4"

updateDate

updateDate: "timestamp" = "timestamp"

updateDateDefault

updateDateDefault: string = "now()"

version

version: "int4" = "int4"

Generated using TypeDoc