Version: 4.3

Class: AbstractSqlConnection

Hierarchy

  • Connection

    AbstractSqlConnection

Constructors

constructor

+ new AbstractSqlConnection(config: Configuration, options?: ConnectionOptions, type?: "read" | "write"): AbstractSqlConnection

Overrides MongoConnection.constructor

Defined in packages/knex/src/AbstractSqlConnection.ts:9

Parameters:

NameType
configConfiguration
options?ConnectionOptions
type?"read" | "write"

Returns: AbstractSqlConnection

Properties

client

Protected client: Knex

Overrides void

Defined in packages/knex/src/AbstractSqlConnection.ts:9


config

Protected Readonly config: Configuration

Inherited from AbstractSqlConnection.config

Defined in packages/core/dist/connections/Connection.d.ts:6


metadata

Protected metadata: MetadataStorage

Inherited from AbstractSqlConnection.metadata

Defined in packages/core/dist/connections/Connection.d.ts:9


options

Protected Optional Readonly options: ConnectionOptions | undefined

Inherited from AbstractSqlConnection.options

Defined in packages/core/dist/connections/Connection.d.ts:7


platform

Protected platform: AbstractSqlPlatform

Overrides MongoConnection.platform

Defined in packages/knex/src/AbstractSqlConnection.ts:8


type

Protected Readonly type: "read" | "write"

Inherited from AbstractSqlConnection.type

Defined in packages/core/dist/connections/Connection.d.ts:8

Methods

begin

begin(ctx?: KnexTransaction): Promise<KnexTransaction>

Overrides void

Defined in packages/knex/src/AbstractSqlConnection.ts:37

Parameters:

NameType
ctx?KnexTransaction

Returns: Promise<KnexTransaction>


close

close(force?: boolean): Promise<void>

Overrides void

Defined in packages/knex/src/AbstractSqlConnection.ts:20

Parameters:

NameType
force?boolean

Returns: Promise<void>


commit

commit(ctx: KnexTransaction): Promise<void>

Overrides void

Defined in packages/knex/src/AbstractSqlConnection.ts:41

Parameters:

NameType
ctxKnexTransaction

Returns: Promise<void>


connect

Abstractconnect(): Promise<void>

Inherited from AbstractSqlConnection.connect

Defined in packages/core/dist/connections/Connection.d.ts:16

Establishes connection to database

Returns: Promise<void>


createKnexClient

ProtectedcreateKnexClient(type: string): Knex

Defined in packages/knex/src/AbstractSqlConnection.ts:84

Parameters:

NameType
typestring

Returns: Knex


execute

execute<T>(queryOrKnex: string | QueryBuilder | Raw, params?: any[], method?: "all" | "get" | "run", ctx?: Transaction): Promise<T>

Overrides void

Defined in packages/knex/src/AbstractSqlConnection.ts:49

Type parameters:

NameTypeDefault
TQueryResult | EntityData<AnyEntity> | EntityData<AnyEntity>[]EntityData\<AnyEntity>[]

Parameters:

NameTypeDefault value
queryOrKnexstring | QueryBuilder | Raw-
paramsany[][]
method"all" | "get" | "run""all"
ctx?Transaction-

Returns: Promise<T>


executeQuery

ProtectedexecuteQuery<T>(query: string, cb: () => Promise<T>): Promise<T>

Inherited from AbstractSqlConnection.executeQuery

Defined in packages/core/dist/connections/Connection.d.ts:38

Type parameters:

Name
T

Parameters:

NameType
querystring
cb() => Promise<T>

Returns: Promise<T>


getClientUrl

getClientUrl(): string

Inherited from AbstractSqlConnection.getClientUrl

Defined in packages/core/dist/connections/Connection.d.ts:35

Returns: string


getConnectionOptions

getConnectionOptions(): ConnectionConfig

Inherited from AbstractSqlConnection.getConnectionOptions

Defined in packages/core/dist/connections/Connection.d.ts:34

Returns: ConnectionConfig


getDefaultClientUrl

AbstractgetDefaultClientUrl(): string

Inherited from AbstractSqlConnection.getDefaultClientUrl

Defined in packages/core/dist/connections/Connection.d.ts:28

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

Returns: string


getKnex

getKnex(): Knex

Defined in packages/knex/src/AbstractSqlConnection.ts:16

Returns: Knex


getKnexOptions

ProtectedgetKnexOptions(type: string): Config

Defined in packages/knex/src/AbstractSqlConnection.ts:93

Parameters:

NameType
typestring

Returns: Config


getSql

PrivategetSql(query: string, formatted: string): string

Defined in packages/knex/src/AbstractSqlConnection.ts:101

Parameters:

NameType
querystring
formattedstring

Returns: string


isConnected

isConnected(): Promise<boolean>

Overrides void

Defined in packages/knex/src/AbstractSqlConnection.ts:24

Returns: Promise<boolean>


loadFile

loadFile(path: string): Promise<void>

Defined in packages/knex/src/AbstractSqlConnection.ts:75

Execute raw SQL queries from file

Parameters:

NameType
pathstring

Returns: Promise<void>


logQuery

ProtectedlogQuery(query: string, took?: number): void

Overrides void

Defined in packages/knex/src/AbstractSqlConnection.ts:80

Parameters:

NameType
querystring
took?number

Returns: void


patchKnexClient

PrivatepatchKnexClient(): void

Defined in packages/knex/src/AbstractSqlConnection.ts:120

do not call positionBindings when there are no bindings - it was messing up with already interpolated strings containing ?, and escaping that was not enough to support edge cases like \\? strings (as positionBindings was removing the \\)

Returns: void


rollback

rollback(ctx: KnexTransaction): Promise<void>

Overrides void

Defined in packages/knex/src/AbstractSqlConnection.ts:45

Parameters:

NameType
ctxKnexTransaction

Returns: Promise<void>


setMetadata

setMetadata(metadata: MetadataStorage): void

Inherited from AbstractSqlConnection.setMetadata

Defined in packages/core/dist/connections/Connection.d.ts:36

Parameters:

NameType
metadataMetadataStorage

Returns: void


setPlatform

setPlatform(platform: Platform): void

Inherited from AbstractSqlConnection.setPlatform

Defined in packages/core/dist/connections/Connection.d.ts:37

Parameters:

NameType
platformPlatform

Returns: void


transactional

transactional<T>(cb: (trx: Transaction<KnexTransaction>) => Promise<T>, ctx?: Transaction<KnexTransaction>): Promise<T>

Overrides void

Defined in packages/knex/src/AbstractSqlConnection.ts:33

Type parameters:

Name
T

Parameters:

NameType
cb(trx: Transaction<KnexTransaction>) => Promise<T>
ctx?Transaction<KnexTransaction>

Returns: Promise<T>


transformRawResult

Protected AbstracttransformRawResult<T>(res: any, method: "all" | "get" | "run"): T

Defined in packages/knex/src/AbstractSqlConnection.ts:145

Type parameters:

Name
T

Parameters:

NameType
resany
method"all" | "get" | "run"

Returns: T

Last updated on by Martin Adámek