Options
All
  • Public
  • Public/Protected
  • All
Menu

Organizes communication with SQL Server DBMS.

Hierarchy

  • SqlServerDriver

Implements

Index

Constructors

constructor

Properties

connection

connection: Connection

Connection used by driver.

Optional database

database: undefined | 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.

mssql

mssql: any

SQL Server library.

options

Connection options.

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","bigint","bit","decimal","money","numeric","smallint","smallmoney","tinyint","float","real","date","datetime2","datetime","datetimeoffset","smalldatetime","time","char","varchar","text","nchar","nvarchar","ntext","binary","image","varbinary","hierarchyid","sql_variant","timestamp","uniqueidentifier","xml","geometry","geography","rowversion"]

Gets list of supported column data types by a driver.

see

https://docs.microsoft.com/en-us/sql/t-sql/data-types/data-types-transact-sql

treeSupport

treeSupport: boolean = true

Indicates if tree tables are supported by this driver.

withLengthColumnTypes

withLengthColumnTypes: ColumnType[] = ["char","varchar","nchar","nvarchar","binary","varbinary"]

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

withPrecisionColumnTypes

withPrecisionColumnTypes: ColumnType[] = ["decimal","numeric","time","datetime2","datetimeoffset"]

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

withScaleColumnTypes

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

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

Methods

afterConnect

  • afterConnect(): Promise<void>

buildTableName

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

    Parameters

    • tableName: string
    • Optional schema: undefined | string
    • Optional database: undefined | string

    Returns string

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

findChangedColumns

getColumnLength

isReturningSqlSupported

  • isReturningSqlSupported(): boolean

isUUIDGenerationSupported

  • isUUIDGenerationSupported(): boolean

Protected loadDependencies

  • loadDependencies(): void

normalizeDefault

normalizeIsUnique

normalizeType

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

    Parameters

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

    Returns string

obtainMasterConnection

  • obtainMasterConnection(): Promise<any>

obtainSlaveConnection

  • obtainSlaveConnection(): Promise<any>

parametrizeMap

  • Sql server's parameters needs to be wrapped into special object with type information about this value. This method wraps all values of the given object into MssqlParameter based on their column definitions in the given table.

    Parameters

    Returns ObjectLiteral

parametrizeValue

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.

binary

binary: object

length

length: number = 1

char

char: object

length

length: number = 1

datetime2

datetime2: object

precision

precision: number = 7

datetimeoffset

datetimeoffset: object

precision

precision: number = 7

decimal

decimal: object

precision

precision: number = 18

scale

scale: number = 0

nchar

nchar: object

length

length: number = 1

numeric

numeric: object

precision

precision: number = 18

scale

scale: number = 0

nvarchar

nvarchar: object

length

length: number = 255

time

time: object

precision

precision: number = 7

varbinary

varbinary: object

length

length: number = 1

varchar

varchar: object

length

length: number = 255

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: "int" = "int"

cacheId

cacheId: "int" = "int"

cacheIdentifier

cacheIdentifier: "nvarchar" = "nvarchar"

cacheQuery

cacheQuery: any = "nvarchar(MAX)" as any

cacheResult

cacheResult: any = "nvarchar(MAX)" as any

cacheTime

cacheTime: "bigint" = "bigint"

createDate

createDate: "datetime2" = "datetime2"

createDateDefault

createDateDefault: string = "getdate()"

migrationId

migrationId: "int" = "int"

migrationName

migrationName: "varchar" = "varchar"

migrationTimestamp

migrationTimestamp: "bigint" = "bigint"

treeLevel

treeLevel: "int" = "int"

updateDate

updateDate: "datetime2" = "datetime2"

updateDateDefault

updateDateDefault: string = "getdate()"

version

version: "int" = "int"

Generated using TypeDoc