Skip to main content
Version: 5.9

abstractDatabaseDriver <C>

Hierarchy

  • DatabaseDriver
    • AbstractSqlDriver
    • MongoDriver

Implements

  • IDatabaseDriver<C>

Index

Properties

[EntityManagerType]

[EntityManagerType]: EntityManager<DatabaseDriver<C>>

readonlyconfig

config: Configuration<IDatabaseDriver<Connection>>

Methods

aggregate

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

    • entityName: string
    • pipeline: any[]

    Returns Promise<any[]>

close

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

    • optionalforce: boolean

    Returns Promise<void>

connect

  • connect(): Promise<C>
  • Returns Promise<C>

convertException

  • convertException(exception: Error): DriverException
  • Converts native db errors to standardized driver exceptions


    Parameters

    • exception: Error

    Returns DriverException

abstractcount

  • count<T, P>(entityName: string, where: FilterQuery<T>, options?: CountOptions<T, P>): Promise<number>
  • Type parameters

    • T: object
    • P: string = never

    Parameters

    • entityName: string
    • where: FilterQuery<T>
    • optionaloptions: CountOptions<T, P>

    Returns Promise<number>

countVirtual

  • countVirtual<T>(entityName: string, where: FilterQuery<T>, options: CountOptions<T, any>): Promise<number>
  • Type parameters

    • T: object

    Parameters

    • entityName: string
    • where: FilterQuery<T>
    • options: CountOptions<T, any>

    Returns Promise<number>

createEntityManager

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

    • D: IDatabaseDriver<Connection, D> = IDatabaseDriver<Connection>

    Parameters

    • optionaluseContext: boolean

    Returns D[typeof EntityManagerType]

ensureIndexes

  • ensureIndexes(): Promise<void>
  • Returns Promise<void>

abstractfind

  • find<T, P>(entityName: string, where: FilterQuery<T>, options?: FindOptions<T, P>): Promise<EntityData<T>[]>
  • Finds selection of entities


    Type parameters

    • T: object
    • P: string = never

    Parameters

    • entityName: string
    • where: FilterQuery<T>
    • optionaloptions: FindOptions<T, P>

    Returns Promise<EntityData<T>[]>

abstractfindOne

  • findOne<T, P>(entityName: string, where: FilterQuery<T>, options?: FindOneOptions<T, P>): Promise<null | EntityData<T>>
  • Finds single entity (table row, document)


    Type parameters

    • T: object
    • P: string = never

    Parameters

    • entityName: string
    • where: FilterQuery<T>
    • optionaloptions: FindOneOptions<T, P>

    Returns Promise<null | EntityData<T>>

findVirtual

  • findVirtual<T>(entityName: string, where: FilterQuery<T>, options: FindOptions<T, any>): Promise<EntityData<T>[]>
  • Type parameters

    • T: object

    Parameters

    • entityName: string
    • where: FilterQuery<T>
    • options: FindOptions<T, any>

    Returns Promise<EntityData<T>[]>

getConnection

  • getConnection(type?: ConnectionType): C
  • Parameters

    • type: ConnectionType = 'write'

    Returns C

getDependencies

  • getDependencies(): string[]
  • 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[]

getMetadata

  • getMetadata(): MetadataStorage
  • Returns MetadataStorage

getPlatform

  • getPlatform(): Platform
  • Returns Platform

init

  • init(): Promise<void>
  • Returns Promise<void>

loadFromPivotTable

  • loadFromPivotTable<T, O>(prop: EntityProperty<any>, owners: Primary<O>[][], where?: FilterQuery<any>, orderBy?: QueryOrderMap<T>[], ctx?: any, options?: FindOptions<T, any>): Promise<Dictionary<T[]>>
  • When driver uses pivot tables for M:N, this method will load identifiers for given collections from them


    Type parameters

    • T: object
    • O: object

    Parameters

    • prop: EntityProperty<any>
    • owners: Primary<O>[][]
    • optionalwhere: FilterQuery<any>
    • optionalorderBy: QueryOrderMap<T>[]
    • optionalctx: any
    • optionaloptions: FindOptions<T, any>

    Returns Promise<Dictionary<T[]>>

lockPessimistic

  • lockPessimistic<T>(entity: T, options: LockOptions): Promise<void>
  • Type parameters

    • T

    Parameters

    • entity: T
    • options: LockOptions

    Returns Promise<void>

mapResult

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

    • T: object

    Parameters

    • result: EntityDictionary<T>
    • optionalmeta: EntityMetadata<T>
    • populate: PopulateOptions<T>[] = []

    Returns null | EntityData<T>

abstractnativeDelete

  • nativeDelete<T>(entityName: string, where: FilterQuery<T>, options?: DeleteOptions<T>): Promise<QueryResult<T>>
  • Type parameters

    • T: object

    Parameters

    • entityName: string
    • where: FilterQuery<T>
    • optionaloptions: DeleteOptions<T>

    Returns Promise<QueryResult<T>>

abstractnativeInsert

  • nativeInsert<T>(entityName: string, data: EntityDictionary<T>, options?: NativeInsertUpdateOptions<T>): Promise<QueryResult<T>>
  • Type parameters

    • T: object

    Parameters

    • entityName: string
    • data: EntityDictionary<T>
    • optionaloptions: NativeInsertUpdateOptions<T>

    Returns Promise<QueryResult<T>>

abstractnativeInsertMany

  • nativeInsertMany<T>(entityName: string, data: EntityDictionary<T>[], options?: NativeInsertUpdateManyOptions<T>): Promise<QueryResult<T>>
  • Type parameters

    • T: object

    Parameters

    • entityName: string
    • data: EntityDictionary<T>[]
    • optionaloptions: NativeInsertUpdateManyOptions<T>

    Returns Promise<QueryResult<T>>

abstractnativeUpdate

  • nativeUpdate<T>(entityName: string, where: FilterQuery<T>, data: EntityDictionary<T>, options?: NativeInsertUpdateOptions<T>): Promise<QueryResult<T>>
  • Type parameters

    • T: object

    Parameters

    • entityName: string
    • where: FilterQuery<T>
    • data: EntityDictionary<T>
    • optionaloptions: NativeInsertUpdateOptions<T>

    Returns Promise<QueryResult<T>>

nativeUpdateMany

  • nativeUpdateMany<T>(entityName: string, where: FilterQuery<T>[], data: EntityDictionary<T>[], options?: NativeInsertUpdateManyOptions<T>): Promise<QueryResult<T>>
  • Type parameters

    • T: object

    Parameters

    • entityName: string
    • where: FilterQuery<T>[]
    • data: EntityDictionary<T>[]
    • optionaloptions: NativeInsertUpdateManyOptions<T>

    Returns Promise<QueryResult<T>>

reconnect

  • reconnect(): Promise<C>
  • Returns Promise<C>

setMetadata

  • setMetadata(metadata: MetadataStorage): void
  • Parameters

    • metadata: MetadataStorage

    Returns void

syncCollection

  • syncCollection<T, O>(coll: Collection<T, O>, options?: DriverMethodOptions): Promise<void>
  • Type parameters

    • T: object
    • O: object

    Parameters

    • coll: Collection<T, O>
    • optionaloptions: DriverMethodOptions

    Returns Promise<void>