Skip to main content
Version: 4.5

Class: AbstractSqlConnection#

knex.AbstractSqlConnection

Hierarchy#

Constructors#

constructor#

+ new AbstractSqlConnection(config: Configuration<IDatabaseDriver<Connection>>, options?: ConnectionOptions, type?: read | write): AbstractSqlConnection

Parameters:#

NameType
configConfiguration<IDatabaseDriver<Connection>>
options?ConnectionOptions
type?read | write

Returns: AbstractSqlConnection

Overrides: Connection

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

Properties#

client#

Protected client: Knex<any, unknown[]>

Overrides: Connection.client

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


config#

Protected Readonly config: Configuration<IDatabaseDriver<Connection>>

Inherited from: Connection.config


metadata#

Protected metadata: MetadataStorage

Inherited from: Connection.metadata

Defined in: packages/core/src/connections/Connection.ts:12


options#

Protected Optional Readonly options: ConnectionOptions

Inherited from: Connection.options


platform#

Protected platform: AbstractSqlPlatform

Overrides: Connection.platform

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


type#

Protected Readonly type: read | write= 'write'

Inherited from: Connection.type

Methods#

begin#

begin(ctx?: Transaction<any, any>, eventBroadcaster?: TransactionEventBroadcaster): Promise<Transaction<any, any>>

Parameters:#

NameType
ctx?Transaction<any, any>
eventBroadcaster?TransactionEventBroadcaster

Returns: Promise<Transaction<any, any>>

Overrides: Connection

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


close#

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

Parameters:#

NameType
force?boolean

Returns: Promise<void>

Overrides: Connection

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


commit#

commit(ctx: Transaction<any, any>, eventBroadcaster?: TransactionEventBroadcaster): Promise<void>

Parameters:#

NameType
ctxTransaction<any, any>
eventBroadcaster?TransactionEventBroadcaster

Returns: Promise<void>

Overrides: Connection

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


connect#

Abstractconnect(): Promise<void>

Establishes connection to database

Returns: Promise<void>

Inherited from: Connection

Defined in: packages/core/src/connections/Connection.ts:28


createKnexClient#

ProtectedcreateKnexClient(type: string): Knex<any, unknown[]>

Parameters:#

NameType
typestring

Returns: Knex<any, unknown[]>

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


execute#

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

Type parameters:#

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

Parameters:#

NameTypeDefault value
queryOrKnexstring | QueryBuilder<any, any> | Raw<any>-
paramsany[]-
methodall | get | run'all'
ctx?any-

Returns: Promise<T>

Overrides: Connection

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


executeQuery#

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

Type parameters:#

Name
T

Parameters:#

NameType
querystring
cb() => Promise<T>

Returns: Promise<T>

Inherited from: Connection

Defined in: packages/core/src/connections/Connection.ts:90


getClientUrl#

getClientUrl(): string

Returns: string

Inherited from: Connection

Defined in: packages/core/src/connections/Connection.ts:75


getConnectionOptions#

getConnectionOptions(): ConnectionConfig

Returns: ConnectionConfig

Inherited from: Connection

Defined in: packages/core/src/connections/Connection.ts:63


getDefaultClientUrl#

AbstractgetDefaultClientUrl(): string

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

Returns: string

Inherited from: Connection

Defined in: packages/core/src/connections/Connection.ts:43


getKnex#

getKnex(): Knex<any, unknown[]>

Returns: Knex<any, unknown[]>

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


getKnexOptions#

ProtectedgetKnexOptions(type: string): Config<any>

Parameters:#

NameType
typestring

Returns: Config<any>

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


getSql#

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

Parameters:#

NameType
querystring
formattedstring

Returns: string

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


isConnected#

isConnected(): Promise<boolean>

Returns: Promise<boolean>

Overrides: Connection

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


loadFile#

loadFile(path: string): Promise<void>

Execute raw SQL queries from file

Parameters:#

NameType
pathstring

Returns: Promise<void>

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


logQuery#

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

Parameters:#

NameType
querystring
took?number

Returns: void

Overrides: Connection

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


patchKnexClient#

PrivatepatchKnexClient(): void

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

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


rollback#

rollback(ctx: Transaction<any, any>, eventBroadcaster?: TransactionEventBroadcaster): Promise<void>

Parameters:#

NameType
ctxTransaction<any, any>
eventBroadcaster?TransactionEventBroadcaster

Returns: Promise<void>

Overrides: Connection

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


setMetadata#

setMetadata(metadata: MetadataStorage): void

Parameters:#

NameType
metadataMetadataStorage

Returns: void

Inherited from: Connection

Defined in: packages/core/src/connections/Connection.ts:82


setPlatform#

setPlatform(platform: Platform): void

Parameters:#

NameType
platformPlatform

Returns: void

Inherited from: Connection

Defined in: packages/core/src/connections/Connection.ts:86


transactional#

transactional<T>(cb: (trx: Transaction<any, any>) => Promise<T>, ctx?: Transaction<any, any>, eventBroadcaster?: TransactionEventBroadcaster): Promise<T>

Type parameters:#

Name
T

Parameters:#

NameType
cb(trx: Transaction<any, any>) => Promise<T>
ctx?Transaction<any, any>
eventBroadcaster?TransactionEventBroadcaster

Returns: Promise<T>

Overrides: Connection

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


transformRawResult#

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

Type parameters:#

Name
T

Parameters:#

NameType
resany
methodall | get | run

Returns: T

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

Last updated on by Renovate Bot