import { EntityData, EntityMetadata, EntityProperty, AnyEntity, FilterQuery, Primary, Dictionary, QBFilterQuery, IPrimaryKey, Populate, PopulateOptions } from '../typings'; import { Connection, QueryResult, Transaction } from '../connections'; import { LockMode, QueryOrderMap, QueryFlag, LoadStrategy } from '../enums'; import { Platform } from '../platforms'; import { MetadataStorage } from '../metadata'; import { Collection } from '../entity'; import { EntityManager } from '../EntityManager'; import { DriverException } from '../exceptions'; export declare const EntityManagerType: unique symbol; export interface IDatabaseDriver { [EntityManagerType]: EntityManager; createEntityManager(useContext?: boolean): D[typeof EntityManagerType]; connect(): Promise; close(force?: boolean): Promise; reconnect(): Promise; getConnection(type?: 'read' | 'write'): C; /** * Finds selection of entities */ find>(entityName: string, where: FilterQuery, options?: FindOptions, ctx?: Transaction): Promise; /** * Finds single entity (table row, document) */ findOne>(entityName: string, where: FilterQuery, options?: FindOneOptions, ctx?: Transaction): Promise; nativeInsert>(entityName: string, data: EntityData, ctx?: Transaction): Promise; nativeInsertMany>(entityName: string, data: EntityData[], ctx?: Transaction): Promise; nativeUpdate>(entityName: string, where: FilterQuery, data: EntityData, ctx?: Transaction): Promise; nativeDelete>(entityName: string, where: FilterQuery, ctx?: Transaction): Promise; syncCollection(collection: Collection, ctx?: Transaction): Promise; count>(entityName: string, where: FilterQuery, ctx?: Transaction): Promise; aggregate(entityName: string, pipeline: any[]): Promise; mapResult>(result: EntityData, meta: EntityMetadata, populate?: PopulateOptions[]): T | null; /** * When driver uses pivot tables for M:N, this method will load identifiers for given collections from them */ loadFromPivotTable, O extends AnyEntity>(prop: EntityProperty, owners: Primary[][], where?: FilterQuery, orderBy?: QueryOrderMap, ctx?: Transaction): Promise>; getPlatform(): Platform; setMetadata(metadata: MetadataStorage): void; ensureIndexes(): Promise; /** * 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 */ getDependencies(): string[]; lockPessimistic>(entity: T, mode: LockMode, ctx?: Transaction): Promise; /** * Converts native db errors to standardized driver exceptions */ convertException(exception: Error): DriverException; } export interface FindOptions = Populate> { populate?: P; orderBy?: QueryOrderMap; limit?: number; offset?: number; refresh?: boolean; convertCustomTypes?: boolean; fields?: string[]; schema?: string; flags?: QueryFlag[]; groupBy?: string | string[]; having?: QBFilterQuery; strategy?: LoadStrategy; filters?: Dictionary | string[] | boolean; } export interface FindOneOptions = Populate> extends Omit, 'limit' | 'offset'> { lockMode?: LockMode; lockVersion?: number | Date; } export interface FindOneOrFailOptions = Populate> extends FindOneOptions { failHandler?: (entityName: string, where: Dictionary | IPrimaryKey | any) => Error; } export interface CountOptions { filters?: Dictionary | string[] | boolean; } export interface UpdateOptions { filters?: Dictionary | string[] | boolean; } export interface DeleteOptions { filters?: Dictionary | string[] | boolean; }