Skip to main content
Version: 4.4

Class: AbstractSqlDriver<C>#

knex.AbstractSqlDriver

Type parameters#

NameTypeDefault
CAbstractSqlConnectionAbstractSqlConnection

Hierarchy#

Constructors#

constructor#

+ Protectednew AbstractSqlDriver<C>(config: Configuration<IDatabaseDriver<Connection>>, platform: AbstractSqlPlatform, connection: Constructor<C>, connector: string[]): AbstractSqlDriver<C>

Type parameters:#

NameTypeDefault
CAbstractSqlConnection<C>AbstractSqlConnection

Parameters:#

NameType
configConfiguration<IDatabaseDriver<Connection>>
platformAbstractSqlPlatform
connectionConstructor<C>
connectorstring[]

Returns: AbstractSqlDriver<C>

Inherited from: DatabaseDriver

Defined in: packages/knex/src/AbstractSqlDriver.ts:19

Properties#

__@EntityManagerType@43871#

__@EntityManagerType@43871: EntityManager<AbstractSqlDriver<C>>

Overrides: DatabaseDriver.__@EntityManagerType@43871

Defined in: packages/knex/src/AbstractSqlDriver.ts:15


comparator#

Protected comparator: EntityComparator

Inherited from: DatabaseDriver.comparator

Defined in: packages/core/src/drivers/DatabaseDriver.ts:21


config#

Protected Readonly config: Configuration<IDatabaseDriver<Connection>>

Inherited from: DatabaseDriver.config


connection#

Protected Readonly connection: C

Overrides: DatabaseDriver.connection

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


dependencies#

Protected Readonly dependencies: string[]

Inherited from: DatabaseDriver.dependencies


logger#

Protected Readonly logger: Logger

Inherited from: DatabaseDriver.logger

Defined in: packages/core/src/drivers/DatabaseDriver.ts:20


metadata#

Protected metadata: MetadataStorage

Inherited from: DatabaseDriver.metadata

Defined in: packages/core/src/drivers/DatabaseDriver.ts:22


platform#

Protected Readonly platform: AbstractSqlPlatform

Overrides: DatabaseDriver.platform

Defined in: packages/knex/src/AbstractSqlDriver.ts:19


replicas#

Protected Readonly replicas: C[]

Overrides: DatabaseDriver.replicas

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

Methods#

aggregate#

aggregate(entityName: string, pipeline: any[]): Promise<any[]>

Parameters:#

NameType
entityNamestring
pipelineany[]

Returns: Promise<any[]>

Inherited from: DatabaseDriver

Defined in: packages/core/src/drivers/DatabaseDriver.ts:49


appendToCollection#

PrivateappendToCollection<T>(meta: EntityMetadata<T>, collection: EntityData<T>[], relationPojo: EntityData<T>): void

Type parameters:#

NameType
TAnyEntity<T>

Parameters:#

NameType
metaEntityMetadata<T>
collectionEntityData<T>[]
relationPojoEntityData<T>

Returns: void

Defined in: packages/knex/src/AbstractSqlDriver.ts:157


autoJoinOneToOneOwner#

ProtectedautoJoinOneToOneOwner<T>(meta: EntityMetadata<any>, populate: PopulateOptions<T>[], fields?: (string | FieldsMap)[]): PopulateOptions<T>[]

1:1 owner side needs to be marked for population so QB auto-joins the owner id

Type parameters:#

Name
T

Parameters:#

NameTypeDefault value
metaEntityMetadata<any>-
populatePopulateOptions<T>[]-
fields(string | FieldsMap)[]...

Returns: PopulateOptions<T>[]

Defined in: packages/knex/src/AbstractSqlDriver.ts:419


buildFields#

ProtectedbuildFields<T>(meta: EntityMetadata<T>, populate: PopulateOptions<T>[], joinedProps: PopulateOptions<T>[], qb: QueryBuilder<T>, fields?: Field<T>[]): Field<T>[]

Type parameters:#

NameType
TAnyEntity<T>

Parameters:#

NameType
metaEntityMetadata<T>
populatePopulateOptions<T>[]
joinedPropsPopulateOptions<T>[]
qbQueryBuilder<T>
fields?Field<T>[]

Returns: Field<T>[]

Defined in: packages/knex/src/AbstractSqlDriver.ts:586


close#

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

Parameters:#

NameType
force?boolean

Returns: Promise<void>

Inherited from: DatabaseDriver

Defined in: packages/core/src/drivers/DatabaseDriver.ts:93


connect#

connect(): Promise<C>

Returns: Promise<C>

Inherited from: DatabaseDriver

Defined in: packages/core/src/drivers/DatabaseDriver.ts:71


convertException#

convertException(exception: Error): DriverException

inheritdoc

Parameters:#

NameType
exceptionError

Returns: DriverException

Inherited from: DatabaseDriver

Defined in: packages/core/src/drivers/DatabaseDriver.ts:244


count#

count<T>(entityName: string, where: any, options?: CountOptions<T>, ctx?: Transaction<any, any>): Promise<number>

Type parameters:#

NameType
TAnyEntity<T>

Parameters:#

NameTypeDefault value
entityNamestring-
whereany-
optionsCountOptions<T>...
ctx?Transaction<any, any>-

Returns: Promise<number>

Overrides: DatabaseDriver

Defined in: packages/knex/src/AbstractSqlDriver.ts:171


createEntityManager#

createEntityManager<D>(useContext?: boolean): D[typeof EntityManagerType]

Type parameters:#

NameTypeDefault
DIDatabaseDriver<Connection, D>IDatabaseDriver<Connection\>

Parameters:#

NameType
useContext?boolean

Returns: D[typeof EntityManagerType]

Overrides: DatabaseDriver

Defined in: packages/knex/src/AbstractSqlDriver.ts:32


createQueryBuilder#

ProtectedcreateQueryBuilder<T>(entityName: string, ctx?: Transaction<any, any>, write?: boolean, convertCustomTypes?: boolean): QueryBuilder<T>

Type parameters:#

NameType
TAnyEntity<T>

Parameters:#

NameType
entityNamestring
ctx?Transaction<any, any>
write?boolean
convertCustomTypes?boolean

Returns: QueryBuilder<T>

Defined in: packages/knex/src/AbstractSqlDriver.ts:500


createReplicas#

ProtectedcreateReplicas(cb: (c: ConnectionOptions) => C): C[]

Parameters:#

NameType
cb(c: ConnectionOptions) => C

Returns: C[]

Inherited from: DatabaseDriver

Defined in: packages/core/src/drivers/DatabaseDriver.ts:205


ensureIndexes#

ensureIndexes(): Promise<void>

Returns: Promise<void>

Inherited from: DatabaseDriver

Defined in: packages/core/src/drivers/DatabaseDriver.ts:117


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>

Defined in: packages/knex/src/AbstractSqlDriver.ts:412


extractManyToMany#

ProtectedextractManyToMany<T>(entityName: string, data: EntityData<T>): EntityData<T>

Type parameters:#

NameType
TAnyEntity<T>

Parameters:#

NameType
entityNamestring
dataEntityData<T>

Returns: EntityData<T>

Defined in: packages/knex/src/AbstractSqlDriver.ts:510


find#

find<T>(entityName: string, where: FilterQuery<T>, options?: FindOptions<T, Populate<T>>, ctx?: Transaction<any, any>): Promise<EntityData<T>[]>

Type parameters:#

NameType
TAnyEntity<T>

Parameters:#

NameTypeDefault value
entityNamestring-
whereFilterQuery<T>-
optionsFindOptions<T, Populate<T>>...
ctx?Transaction<any, any>-

Returns: Promise<EntityData<T>[]>

Overrides: DatabaseDriver

Defined in: packages/knex/src/AbstractSqlDriver.ts:36


findOne#

findOne<T>(entityName: string, where: FilterQuery<T>, options?: FindOneOptions<T, Populate<T>>, ctx?: Transaction<any, any>): Promise<null | EntityData<T>>

Type parameters:#

NameType
TAnyEntity<T>

Parameters:#

NameType
entityNamestring
whereFilterQuery<T>
options?FindOneOptions<T, Populate<T>>
ctx?Transaction<any, any>

Returns: Promise<null | EntityData<T>>

Overrides: DatabaseDriver

Defined in: packages/knex/src/AbstractSqlDriver.ts:74


getConnection#

getConnection(type?: read | write): C

Parameters:#

NameTypeDefault value
typeread | write'write'

Returns: C

Inherited from: DatabaseDriver

Defined in: packages/core/src/drivers/DatabaseDriver.ts:83


getDependencies#

getDependencies(): string[]

Returns: string[]

Inherited from: DatabaseDriver

Defined in: packages/core/src/drivers/DatabaseDriver.ts:113


getFieldsForJoinedLoad#

ProtectedgetFieldsForJoinedLoad<T>(qb: QueryBuilder<T>, meta: EntityMetadata<T>, populate?: PopulateOptions<T>[], parentTableAlias?: string, parentJoinPath?: string): Field<T>[]

Type parameters:#

NameType
TAnyEntity<T>

Parameters:#

NameTypeDefault value
qbQueryBuilder<T>-
metaEntityMetadata<T>-
populatePopulateOptions<T>[]...
parentTableAlias?string-
parentJoinPath?string-

Returns: Field<T>[]

Defined in: packages/knex/src/AbstractSqlDriver.ts:460


getPivotInverseProperty#

ProtectedgetPivotInverseProperty(prop: EntityProperty<any>): EntityProperty<any>

Parameters:#

NameType
propEntityProperty<any>

Returns: EntityProperty<any>

Inherited from: DatabaseDriver

Defined in: packages/core/src/drivers/DatabaseDriver.ts:190


getPivotOrderBy#

ProtectedgetPivotOrderBy(prop: EntityProperty<any>, orderBy?: QueryOrderMap): QueryOrderMap

Parameters:#

NameType
propEntityProperty<any>
orderBy?QueryOrderMap

Returns: QueryOrderMap

Inherited from: DatabaseDriver

Defined in: packages/core/src/drivers/DatabaseDriver.ts:169


getPlatform#

getPlatform(): AbstractSqlPlatform

Returns: AbstractSqlPlatform

Overrides: DatabaseDriver

Defined in: packages/knex/src/AbstractSqlDriver.ts:28


getPrimaryKeyFields#

ProtectedgetPrimaryKeyFields(entityName: string): string[]

Parameters:#

NameType
entityNamestring

Returns: string[]

Inherited from: DatabaseDriver

Defined in: packages/core/src/drivers/DatabaseDriver.ts:185


inlineEmbeddables#

ProtectedinlineEmbeddables<T>(meta: EntityMetadata<T>, data: T, where?: boolean): void

Type parameters:#

Name
T

Parameters:#

NameType
metaEntityMetadata<T>
dataT
where?boolean

Returns: void

Inherited from: DatabaseDriver

Defined in: packages/core/src/drivers/DatabaseDriver.ts:121


joinedProps#

ProtectedjoinedProps<T>(meta: EntityMetadata<any>, populate: PopulateOptions<T>[]): PopulateOptions<T>[]

Type parameters:#

Name
T

Parameters:#

NameType
metaEntityMetadata<any>
populatePopulateOptions<T>[]

Returns: PopulateOptions<T>[]

Defined in: packages/knex/src/AbstractSqlDriver.ts:432


loadFromPivotTable#

loadFromPivotTable<T, O>(prop: EntityProperty<any>, owners: Primary<O>[][], where?: FilterQuery<T>, orderBy?: QueryOrderMap, ctx?: any, options?: FindOptions<T, Populate<T>>): Promise<Dictionary<T[]>>

Type parameters:#

NameType
TAnyEntity<T>
OAnyEntity<O>

Parameters:#

NameTypeDefault value
propEntityProperty<any>-
ownersPrimary<O>[][]-
whereFilterQuery<T>...
orderBy?QueryOrderMap-
ctx?any-
options?FindOptions<T, Populate<T>>-

Returns: Promise<Dictionary<T[]>>

Overrides: DatabaseDriver

Defined in: packages/knex/src/AbstractSqlDriver.ts:381


lockPessimistic#

lockPessimistic<T>(entity: T, mode: LockMode, ctx?: any): Promise<void>

Type parameters:#

NameType
TAnyEntity<T>

Parameters:#

NameType
entityT
modeLockMode
ctx?any

Returns: Promise<void>

Overrides: DatabaseDriver

Defined in: packages/knex/src/AbstractSqlDriver.ts:578


mapJoinedProps#

PrivatemapJoinedProps<T>(result: EntityData<T>, meta: EntityMetadata<T>, populate: PopulateOptions<T>[], qb: QueryBuilder<T>, root: EntityData<T>, map: Dictionary<any>, parentJoinPath?: string): void

Type parameters:#

NameType
TAnyEntity<T>

Parameters:#

NameType
resultEntityData<T>
metaEntityMetadata<T>
populatePopulateOptions<T>[]
qbQueryBuilder<T>
rootEntityData<T>
mapDictionary<any>
parentJoinPath?string

Returns: void

Defined in: packages/knex/src/AbstractSqlDriver.ts:104


mapPropToFieldNames#

mapPropToFieldNames<T>(qb: QueryBuilder<T>, prop: EntityProperty<T>, tableAlias?: string): Field<T>[]

internal

Type parameters:#

NameType
TAnyEntity<T>

Parameters:#

NameType
qbQueryBuilder<T>
propEntityProperty<T>
tableAlias?string

Returns: Field<T>[]

Defined in: packages/knex/src/AbstractSqlDriver.ts:485


mapResult#

mapResult<T>(result: EntityData<T>, meta: EntityMetadata<T>, populate?: PopulateOptions<T>[], qb?: QueryBuilder<T>, map?: Dictionary<any>): null | EntityData<T>

Type parameters:#

NameType
TAnyEntity<T>

Parameters:#

NameTypeDefault value
resultEntityData<T>-
metaEntityMetadata<T>-
populatePopulateOptions<T>[]...
qb?QueryBuilder<T>-
mapDictionary<any>...

Returns: null | EntityData<T>

Overrides: DatabaseDriver

Defined in: packages/knex/src/AbstractSqlDriver.ts:89


mergeJoinedResult#

mergeJoinedResult<T>(rawResults: EntityData<T>[], meta: EntityMetadata<T>): EntityData<T>[]

internal

Type parameters:#

NameType
TAnyEntity<T>

Parameters:#

NameType
rawResultsEntityData<T>[]
metaEntityMetadata<T>

Returns: EntityData<T>[]

Defined in: packages/knex/src/AbstractSqlDriver.ts:442


nativeDelete#

nativeDelete<T>(entityName: string, where: any, ctx?: Transaction<any, any>): Promise<QueryResult>

Type parameters:#

NameType
TAnyEntity<T>

Parameters:#

NameType
entityNamestring
whereany
ctx?Transaction<any, any>

Returns: Promise<QueryResult>

Overrides: DatabaseDriver

Defined in: packages/knex/src/AbstractSqlDriver.ts:336


nativeInsert#

nativeInsert<T>(entityName: string, data: EntityData<T>, ctx?: Transaction<any, any>, convertCustomTypes?: boolean): Promise<QueryResult>

Type parameters:#

NameType
TAnyEntity<T>

Parameters:#

NameTypeDefault value
entityNamestring-
dataEntityData<T>-
ctx?Transaction<any, any>-
convertCustomTypesbooleantrue

Returns: Promise<QueryResult>

Overrides: DatabaseDriver

Defined in: packages/knex/src/AbstractSqlDriver.ts:184


nativeInsertMany#

nativeInsertMany<T>(entityName: string, data: EntityData<T>[], ctx?: Transaction<any, any>, processCollections?: boolean, convertCustomTypes?: boolean): Promise<QueryResult>

Type parameters:#

NameType
TAnyEntity<T>

Parameters:#

NameTypeDefault value
entityNamestring-
dataEntityData<T>[]-
ctx?Transaction<any, any>-
processCollectionsbooleantrue
convertCustomTypesbooleantrue

Returns: Promise<QueryResult>

Overrides: DatabaseDriver

Defined in: packages/knex/src/AbstractSqlDriver.ts:206


nativeUpdate#

nativeUpdate<T>(entityName: string, where: FilterQuery<T>, data: EntityData<T>, ctx?: Transaction<any, any>, convertCustomTypes?: boolean): Promise<QueryResult>

Type parameters:#

NameType
TAnyEntity<T>

Parameters:#

NameTypeDefault value
entityNamestring-
whereFilterQuery<T>-
dataEntityData<T>-
ctx?Transaction<any, any>-
convertCustomTypesbooleantrue

Returns: Promise<QueryResult>

Overrides: DatabaseDriver

Defined in: packages/knex/src/AbstractSqlDriver.ts:262


nativeUpdateMany#

nativeUpdateMany<T>(entityName: string, where: FilterQuery<T>[], data: EntityData<T>[], ctx?: Transaction<any, any>, processCollections?: boolean, convertCustomTypes?: boolean): Promise<QueryResult>

Type parameters:#

NameType
TAnyEntity<T>

Parameters:#

NameTypeDefault value
entityNamestring-
whereFilterQuery<T>[]-
dataEntityData<T>[]-
ctx?Transaction<any, any>-
processCollectionsbooleantrue
convertCustomTypesbooleantrue

Returns: Promise<QueryResult>

Overrides: DatabaseDriver

Defined in: packages/knex/src/AbstractSqlDriver.ts:286


processManyToMany#

ProtectedprocessManyToMany<T>(meta: undefined | EntityMetadata<T>, pks: Primary<T>[], collections: EntityData<T>, clear: boolean, ctx?: Transaction<any, any>): Promise<void>

Type parameters:#

NameType
TAnyEntity<T>

Parameters:#

NameType
metaundefined | EntityMetadata<T>
pksPrimary<T>[]
collectionsEntityData<T>
clearboolean
ctx?Transaction<any, any>

Returns: Promise<void>

Defined in: packages/knex/src/AbstractSqlDriver.ts:527


reconnect#

reconnect(): Promise<C>

Returns: Promise<C>

Inherited from: DatabaseDriver

Defined in: packages/core/src/drivers/DatabaseDriver.ts:78


rethrow#

Protectedrethrow<T>(promise: Promise<T>): Promise<T>

Type parameters:#

Name
T

Parameters:#

NameType
promisePromise<T>

Returns: Promise<T>

Inherited from: DatabaseDriver

Defined in: packages/core/src/drivers/DatabaseDriver.ts:252


setMetadata#

setMetadata(metadata: MetadataStorage): void

Parameters:#

NameType
metadataMetadataStorage

Returns: void

Inherited from: DatabaseDriver

Defined in: packages/core/src/drivers/DatabaseDriver.ts:102


shouldHaveColumn#

shouldHaveColumn<T>(prop: EntityProperty<T>, populate: PopulateOptions<T>[], includeFormulas?: boolean): boolean

internal

Type parameters:#

NameType
TAnyEntity<T>

Parameters:#

NameTypeDefault value
propEntityProperty<T>-
populatePopulateOptions<T>[]-
includeFormulasbooleantrue

Returns: boolean

Inherited from: DatabaseDriver

Defined in: packages/core/src/drivers/DatabaseDriver.ts:225


syncCollection#

syncCollection<T, O>(coll: Collection<T, O>, ctx?: any): Promise<void>

Type parameters:#

NameType
TAnyEntity<T>
OAnyEntity<O>

Parameters:#

NameType
collCollection<T, O>
ctx?any

Returns: Promise<void>

Overrides: DatabaseDriver

Defined in: packages/knex/src/AbstractSqlDriver.ts:348


updateCollectionDiff#

ProtectedupdateCollectionDiff<T, O>(meta: EntityMetadata<O>, prop: EntityProperty<T>, pks: Primary<O>[], deleteDiff: boolean | Primary<T>[][], insertDiff: Primary<T>[][], ctx?: any): Promise<void>

Type parameters:#

NameType
TAnyEntity<T>
OAnyEntity<O>

Parameters:#

NameType
metaEntityMetadata<O>
propEntityProperty<T>
pksPrimary<O>[]
deleteDiffboolean | Primary<T>[][]
insertDiffPrimary<T>[][]
ctx?any

Returns: Promise<void>

Defined in: packages/knex/src/AbstractSqlDriver.ts:539

Last updated on by Martin Adámek