Version: 4.3

Class: Connection

Hierarchy

  • Connection

Constructors

constructor

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

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

Parameters:

NameTypeDefault value
configConfiguration-
options?ConnectionOptions-
type"read" | "write""write"

Returns: Connection

Properties

client

Protected Abstract client: any

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


config

Protected Readonly config: Configuration

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


metadata

Protected metadata: MetadataStorage

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


options

Protected Optional Readonly options: ConnectionOptions

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


platform

Protected platform: Platform

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


type

Protected Readonly type: "read" | "write"

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

Methods

begin

begin(ctx?: Transaction): Promise<unknown>

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

Parameters:

NameType
ctx?Transaction

Returns: Promise<unknown>


close

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

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

Closes the database connection (aka disconnect)

Parameters:

NameType
force?boolean

Returns: Promise<void>


commit

commit(ctx: Transaction): Promise<void>

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

Parameters:

NameType
ctxTransaction

Returns: Promise<void>


connect

Abstractconnect(): Promise<void>

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

Establishes connection to database

Returns: Promise<void>


execute

Abstractexecute(query: string, params?: any[], method?: "all" | "get" | "run", ctx?: Transaction): Promise<QueryResult | any | any[]>

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

Parameters:

NameType
querystring
params?any[]
method?"all" | "get" | "run"
ctx?Transaction

Returns: Promise<QueryResult | any | any[]>


executeQuery

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

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

Type parameters:

Name
T

Parameters:

NameType
querystring
cb() => Promise<T>

Returns: Promise<T>


getClientUrl

getClientUrl(): string

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

Returns: string


getConnectionOptions

getConnectionOptions(): ConnectionConfig

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

Returns: ConnectionConfig


getDefaultClientUrl

AbstractgetDefaultClientUrl(): string

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

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

Returns: string


isConnected

AbstractisConnected(): Promise<boolean>

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

Are we connected to the database

Returns: Promise<boolean>


logQuery

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

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

Parameters:

NameType
querystring
took?number

Returns: void


rollback

rollback(ctx: Transaction): Promise<void>

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

Parameters:

NameType
ctxTransaction

Returns: Promise<void>


setMetadata

setMetadata(metadata: MetadataStorage): void

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

Parameters:

NameType
metadataMetadataStorage

Returns: void


setPlatform

setPlatform(platform: Platform): void

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

Parameters:

NameType
platformPlatform

Returns: void


transactional

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

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

Type parameters:

Name
T

Parameters:

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

Returns: Promise<T>

Last updated on by Martin Adámek