import { EntityData, EntityMetadata, EntityProperty, IEntity, IEntityType, IPrimaryKey } from '../decorators'; import { Connection, QueryResult } from '../connections'; import { QueryOrder } from '../query'; import { Platform } from '../platforms'; export interface IDatabaseDriver { getConnection(): C; /** * Finds selection of entities */ find(entityName: string, where: FilterQuery, populate?: string[], orderBy?: Record, limit?: number, offset?: number): Promise; /** * Finds single entity (table row, document) */ findOne(entityName: string, where: FilterQuery | IPrimaryKey, populate?: string[], orderBy?: Record): Promise; nativeInsert(entityName: string, data: EntityData): Promise; nativeUpdate(entityName: string, where: FilterQuery | IPrimaryKey, data: EntityData): Promise; nativeDelete(entityName: string, where: FilterQuery | IPrimaryKey): Promise; count(entityName: string, where: FilterQuery): Promise; aggregate(entityName: string, pipeline: any[]): Promise; mapResult>(result: T, meta: EntityMetadata): T; /** * When driver uses pivot tables for M:N, this method will load identifiers for given collections from them */ loadFromPivotTable(prop: EntityProperty, owners: IPrimaryKey[]): Promise>; /** * Begins a transaction (if supported) */ beginTransaction(): Promise; /** * Commits statements in a transaction */ commit(): Promise; /** * Rollback changes in a transaction */ rollback(): Promise; /** * Runs callback inside transaction */ transactional(cb: () => Promise): Promise; isInTransaction(): boolean; getPlatform(): Platform; } export type FilterQuery = Partial | Record;