Version: 4.3

Interface: IDatabaseDriver<C>

Type parameters

NameTypeDefault
CConnectionConnection

Hierarchy

  • IDatabaseDriver

Implemented by

Properties

[EntityManagerType]

[EntityManagerType]: EntityManager<this>

Defined in packages/core/src/drivers/IDatabaseDriver.ts:14

Methods

aggregate

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

Defined in packages/core/src/drivers/IDatabaseDriver.ts:50

Parameters:

NameType
entityNamestring
pipelineany[]

Returns: Promise<any[]>


close

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

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

Parameters:

NameType
force?boolean

Returns: Promise<void>


connect

connect(): Promise<C>

Defined in packages/core/src/drivers/IDatabaseDriver.ts:18

Returns: Promise<C>


convertException

convertException(exception: Error): DriverException

Defined in packages/core/src/drivers/IDatabaseDriver.ts:76

Converts native db errors to standardized driver exceptions

Parameters:

NameType
exceptionError

Returns: DriverException


count

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

Defined in packages/core/src/drivers/IDatabaseDriver.ts:48

Type parameters:

NameType
TAnyEntity<T>

Parameters:

NameType
entityNamestring
whereFilterQuery<T>
options?CountOptions<T>
ctx?Transaction

Returns: Promise<number>


createEntityManager

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

Defined in packages/core/src/drivers/IDatabaseDriver.ts:16

Type parameters:

NameTypeDefault
DIDatabaseDriverIDatabaseDriver

Parameters:

NameType
useContext?boolean

Returns: D[typeof EntityManagerType]


ensureIndexes

ensureIndexes(): Promise<void>

Defined in packages/core/src/drivers/IDatabaseDriver.ts:63

Returns: Promise<void>


find

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

Defined in packages/core/src/drivers/IDatabaseDriver.ts:29

Finds selection of entities

Type parameters:

NameType
TAnyEntity<T>

Parameters:

NameType
entityNamestring
whereFilterQuery<T>
options?FindOptions<T>
ctx?Transaction

Returns: Promise<EntityData<T>[]>


findOne

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

Defined in packages/core/src/drivers/IDatabaseDriver.ts:34

Finds single entity (table row, document)

Type parameters:

NameType
TAnyEntity<T>

Parameters:

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

Returns: Promise<EntityData<T> | null>


getConnection

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

Defined in packages/core/src/drivers/IDatabaseDriver.ts:24

Parameters:

NameType
type?"read" | "write"

Returns: C


getDependencies

getDependencies(): string[]

Defined in packages/core/src/drivers/IDatabaseDriver.ts:69

Returns name of the underlying database dependencies (e.g. mongodb or mysql2) for SQL drivers it also returns knex in the array as connectors are not used directly there

Returns: string[]


getPlatform

getPlatform(): Platform

Defined in packages/core/src/drivers/IDatabaseDriver.ts:59

Returns: Platform


loadFromPivotTable

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

Defined in packages/core/src/drivers/IDatabaseDriver.ts:57

When driver uses pivot tables for M:N, this method will load identifiers for given collections from them

Type parameters:

NameType
TAnyEntity<T>
OAnyEntity<O>

Parameters:

NameType
propEntityProperty
ownersPrimary<O>[][]
where?FilterQuery<T>
orderBy?QueryOrderMap
ctx?Transaction

Returns: Promise<Dictionary<T[]>>


lockPessimistic

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

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

Type parameters:

NameType
TAnyEntity<T>

Parameters:

NameType
entityT
modeLockMode
ctx?Transaction

Returns: Promise<void>


mapResult

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

Defined in packages/core/src/drivers/IDatabaseDriver.ts:52

Type parameters:

NameType
TAnyEntity<T>

Parameters:

NameType
resultEntityData<T>
metaEntityMetadata
populate?PopulateOptions<T>[]

Returns: EntityData<T> | null


nativeDelete

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

Defined in packages/core/src/drivers/IDatabaseDriver.ts:44

Type parameters:

NameType
TAnyEntity<T>

Parameters:

NameType
entityNamestring
whereFilterQuery<T>
ctx?Transaction

Returns: Promise<QueryResult>


nativeInsert

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

Defined in packages/core/src/drivers/IDatabaseDriver.ts:36

Type parameters:

NameType
TAnyEntity<T>

Parameters:

NameType
entityNamestring
dataEntityData<T>
ctx?Transaction
convertCustomTypes?boolean

Returns: Promise<QueryResult>


nativeInsertMany

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

Defined in packages/core/src/drivers/IDatabaseDriver.ts:38

Type parameters:

NameType
TAnyEntity<T>

Parameters:

NameType
entityNamestring
dataEntityData<T>[]
ctx?Transaction
processCollections?boolean
convertCustomTypes?boolean

Returns: Promise<QueryResult>


nativeUpdate

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

Defined in packages/core/src/drivers/IDatabaseDriver.ts:40

Type parameters:

NameType
TAnyEntity<T>

Parameters:

NameType
entityNamestring
whereFilterQuery<T>
dataEntityData<T>
ctx?Transaction
convertCustomTypes?boolean

Returns: Promise<QueryResult>


nativeUpdateMany

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

Defined in packages/core/src/drivers/IDatabaseDriver.ts:42

Type parameters:

NameType
TAnyEntity<T>

Parameters:

NameType
entityNamestring
whereFilterQuery<T>[]
dataEntityData<T>[]
ctx?Transaction
processCollections?boolean
convertCustomTypes?boolean

Returns: Promise<QueryResult>


reconnect

reconnect(): Promise<C>

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

Returns: Promise<C>


setMetadata

setMetadata(metadata: MetadataStorage): void

Defined in packages/core/src/drivers/IDatabaseDriver.ts:61

Parameters:

NameType
metadataMetadataStorage

Returns: void


syncCollection

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

Defined in packages/core/src/drivers/IDatabaseDriver.ts:46

Type parameters:

Name
T
O

Parameters:

NameType
collectionCollection<T, O>
ctx?Transaction

Returns: Promise<void>

Last updated on by Martin Adámek