Version: 4.3

Class: AbstractSqlDriver<C>

Type parameters

NameTypeDefault
CAbstractSqlConnectionAbstractSqlConnection

Hierarchy

  • DatabaseDriver<C>

    AbstractSqlDriver

Implements

  • IDatabaseDriver<C>

Constructors

constructor

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

Overrides void

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

Parameters:

NameType
configConfiguration
platformAbstractSqlPlatform
connectionConstructor<C>
connectorstring[]

Returns: AbstractSqlDriver

Properties

[EntityManagerType]

[EntityManagerType]: SqlEntityManager<this>

Overrides void

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


comparator

Protected comparator: EntityComparator

Inherited from AbstractSqlDriver.comparator

Defined in packages/core/dist/drivers/DatabaseDriver.d.ts:19


config

Protected Readonly config: Configuration

Inherited from AbstractSqlDriver.config

Defined in packages/core/dist/drivers/DatabaseDriver.d.ts:12


connection

Protected Readonly connection: C

Overrides void

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


dependencies

Protected Readonly dependencies: string[]

Inherited from AbstractSqlDriver.dependencies

Defined in packages/core/dist/drivers/DatabaseDriver.d.ts:13


logger

Protected Readonly logger: Logger

Inherited from AbstractSqlDriver.logger

Defined in packages/core/dist/drivers/DatabaseDriver.d.ts:18


metadata

Protected metadata: MetadataStorage

Inherited from AbstractSqlDriver.metadata

Defined in packages/core/dist/drivers/DatabaseDriver.d.ts:20


platform

Protected Readonly platform: AbstractSqlPlatform

Overrides void

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


replicas

Protected Readonly replicas: C[] = []

Overrides MongoDriver.replicas

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

Methods

aggregate

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

Inherited from AbstractSqlDriver.aggregate

Defined in packages/core/dist/drivers/DatabaseDriver.d.ts:31

Parameters:

NameType
entityNamestring
pipelineany[]

Returns: Promise<any[]>


appendToCollection

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

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

Type parameters:

NameType
TAnyEntity<T>

Parameters:

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

Returns: void


autoJoinOneToOneOwner

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

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

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-
populatePopulateOptions<T>[]-
fieldsstring[][]

Returns: PopulateOptions<T>[]


buildFields

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

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

Type parameters:

NameType
TAnyEntity<T>

Parameters:

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

Returns: Field<T>[]


close

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

Inherited from AbstractSqlDriver.close

Defined in packages/core/dist/drivers/DatabaseDriver.d.ts:38

Parameters:

NameType
force?boolean

Returns: Promise<void>


connect

connect(): Promise<C>

Inherited from AbstractSqlDriver.connect

Defined in packages/core/dist/drivers/DatabaseDriver.d.ts:35

Returns: Promise<C>


convertException

convertException(exception: Error): DriverException

Inherited from AbstractSqlDriver.convertException

Defined in packages/core/dist/drivers/DatabaseDriver.d.ts:56

inheritdoc

Parameters:

NameType
exceptionError

Returns: DriverException


count

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

Overrides void

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

Type parameters:

NameType
TAnyEntity<T>

Parameters:

NameTypeDefault value
entityNamestring-
whereany-
optionsCountOptions<T>{}
ctx?Transaction<KnexTransaction>-

Returns: Promise<number>


createEntityManager

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

Overrides void

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

Type parameters:

NameTypeDefault
DIDatabaseDriverIDatabaseDriver

Parameters:

NameType
useContext?boolean

Returns: D[typeof EntityManagerType]


createQueryBuilder

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

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

Type parameters:

NameType
TAnyEntity<T>

Parameters:

NameType
entityNamestring
ctx?Transaction<KnexTransaction>
write?boolean
convertCustomTypes?boolean

Returns: QueryBuilder<T>


createReplicas

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

Inherited from AbstractSqlDriver.createReplicas

Defined in packages/core/dist/drivers/DatabaseDriver.d.ts:47

Parameters:

NameType
cb(c: ConnectionOptions) => C

Returns: C[]


ensureIndexes

ensureIndexes(): Promise<void>

Inherited from AbstractSqlDriver.ensureIndexes

Defined in packages/core/dist/drivers/DatabaseDriver.d.ts:42

Returns: Promise<void>


execute

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

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

Type parameters:

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

Parameters:

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

Returns: Promise<T>


extractManyToMany

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

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

Type parameters:

NameType
TAnyEntity<T>

Parameters:

NameType
entityNamestring
dataEntityData<T>

Returns: EntityData<T>


find

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

Overrides void

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

Type parameters:

NameType
TAnyEntity<T>

Parameters:

NameTypeDefault value
entityNamestring-
whereFilterQuery<T>-
optionsFindOptions<T>{}
ctx?Transaction<KnexTransaction>-

Returns: Promise<EntityData<T>[]>


findOne

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

Overrides void

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

Type parameters:

NameType
TAnyEntity<T>

Parameters:

NameType
entityNamestring
whereFilterQuery<T>
options?FindOneOptions<T>
ctx?Transaction<KnexTransaction>

Returns: Promise<EntityData<T> | null>


getConnection

getConnection(type?: "read" | "write"): C

Inherited from AbstractSqlDriver.getConnection

Defined in packages/core/dist/drivers/DatabaseDriver.d.ts:37

Parameters:

NameType
type?"read" | "write"

Returns: C


getDependencies

getDependencies(): string[]

Inherited from AbstractSqlDriver.getDependencies

Defined in packages/core/dist/drivers/DatabaseDriver.d.ts:41

Returns: string[]


getFieldsForJoinedLoad

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

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

Type parameters:

NameType
TAnyEntity<T>

Parameters:

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

Returns: Field<T>[]


getPivotInverseProperty

ProtectedgetPivotInverseProperty(prop: EntityProperty): EntityProperty

Inherited from AbstractSqlDriver.getPivotInverseProperty

Defined in packages/core/dist/drivers/DatabaseDriver.d.ts:46

Parameters:

NameType
propEntityProperty

Returns: EntityProperty


getPivotOrderBy

ProtectedgetPivotOrderBy(prop: EntityProperty, orderBy?: QueryOrderMap): QueryOrderMap

Inherited from AbstractSqlDriver.getPivotOrderBy

Defined in packages/core/dist/drivers/DatabaseDriver.d.ts:44

Parameters:

NameType
propEntityProperty
orderBy?QueryOrderMap

Returns: QueryOrderMap


getPlatform

getPlatform(): AbstractSqlPlatform

Overrides MongoDriver.getPlatform

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

Returns: AbstractSqlPlatform


getPrimaryKeyFields

ProtectedgetPrimaryKeyFields(entityName: string): string[]

Inherited from AbstractSqlDriver.getPrimaryKeyFields

Defined in packages/core/dist/drivers/DatabaseDriver.d.ts:45

Parameters:

NameType
entityNamestring

Returns: string[]


inlineEmbeddables

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

Inherited from AbstractSqlDriver.inlineEmbeddables

Defined in packages/core/dist/drivers/DatabaseDriver.d.ts:43

Type parameters:

Name
T

Parameters:

NameType
metaEntityMetadata<T>
dataT
where?boolean

Returns: void


joinedProps

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

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

Type parameters:

Name
T

Parameters:

NameType
metaEntityMetadata
populatePopulateOptions<T>[]

Returns: PopulateOptions<T>[]


loadFromPivotTable

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

Overrides MongoDriver.loadFromPivotTable

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

Type parameters:

NameType
TAnyEntity<T>
OAnyEntity<O>

Parameters:

NameTypeDefault value
propEntityProperty-
ownersPrimary<O>[][]-
whereFilterQuery<T>{}
orderBy?QueryOrderMap-
ctx?Transaction-

Returns: Promise<Dictionary<T[]>>


lockPessimistic

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

Overrides MongoDriver.lockPessimistic

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

Type parameters:

NameType
TAnyEntity<T>

Parameters:

NameType
entityT
modeLockMode
ctx?Transaction

Returns: Promise<void>


mapJoinedProps

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

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

Type parameters:

NameType
TAnyEntity<T>

Parameters:

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

Returns: void


mapPropToFieldNames

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

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

internal

Type parameters:

NameType
TAnyEntity<T>

Parameters:

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

Returns: Field<T>[]


mapResult

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

Overrides MongoDriver.mapResult

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

Type parameters:

NameType
TAnyEntity<T>

Parameters:

NameTypeDefault value
resultEntityData<T>-
metaEntityMetadata<T>-
populatePopulateOptions<T>[][]
qb?QueryBuilder<T>-
mapDictionary{}

Returns: EntityData<T> | null


mergeJoinedResult

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

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

internal

Type parameters:

NameType
TAnyEntity<T>

Parameters:

NameType
rawResultsDictionary[]
metaEntityMetadata<T>

Returns: EntityData<T>[]


nativeDelete

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

Overrides void

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

Type parameters:

NameType
TAnyEntity<T>

Parameters:

NameType
entityNamestring
whereFilterQuery<T> | string | any
ctx?Transaction<KnexTransaction>

Returns: Promise<QueryResult>


nativeInsert

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

Overrides void

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

Type parameters:

NameType
TAnyEntity<T>

Parameters:

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

Returns: Promise<QueryResult>


nativeInsertMany

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

Overrides void

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

Type parameters:

NameType
TAnyEntity<T>

Parameters:

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

Returns: Promise<QueryResult>


nativeUpdate

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

Overrides void

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

Type parameters:

NameType
TAnyEntity<T>

Parameters:

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

Returns: Promise<QueryResult>


nativeUpdateMany

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

Overrides void

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

Type parameters:

NameType
TAnyEntity<T>

Parameters:

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

Returns: Promise<QueryResult>


processManyToMany

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

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

Type parameters:

NameType
TAnyEntity<T>

Parameters:

NameType
metaEntityMetadata<T> | undefined
pksPrimary<T>[]
collectionsEntityData<T>
clearboolean
ctx?Transaction<KnexTransaction>

Returns: Promise<void>


reconnect

reconnect(): Promise<C>

Inherited from AbstractSqlDriver.reconnect

Defined in packages/core/dist/drivers/DatabaseDriver.d.ts:36

Returns: Promise<C>


rethrow

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

Inherited from AbstractSqlDriver.rethrow

Defined in packages/core/dist/drivers/DatabaseDriver.d.ts:57

Type parameters:

Name
T

Parameters:

NameType
promisePromise<T>

Returns: Promise<T>


setMetadata

setMetadata(metadata: MetadataStorage): void

Inherited from AbstractSqlDriver.setMetadata

Defined in packages/core/dist/drivers/DatabaseDriver.d.ts:40

Parameters:

NameType
metadataMetadataStorage

Returns: void


shouldHaveColumn

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

Inherited from AbstractSqlDriver.shouldHaveColumn

Defined in packages/core/dist/drivers/DatabaseDriver.d.ts:52

internal

Type parameters:

NameType
TAnyEntity<T>

Parameters:

NameType
propEntityProperty<T>
populatePopulateOptions<T>[]
includeFormulas?boolean

Returns: boolean


syncCollection

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

Overrides MongoDriver.syncCollection

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

Type parameters:

NameType
TAnyEntity<T>
OAnyEntity<O>

Parameters:

NameType
collCollection<T, O>
ctx?Transaction

Returns: Promise<void>


updateCollectionDiff

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

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

Type parameters:

NameType
TAnyEntity<T>
OAnyEntity<O>

Parameters:

NameType
metaEntityMetadata<O>
propEntityProperty<T>
pksPrimary<O>[]
deleteDiffPrimary<T>[][] | boolean
insertDiffPrimary<T>[][]
ctx?Transaction

Returns: Promise<void>

Last updated on by Martin Adámek