import type { EntityConfiguration } from './EntityConfiguration.ts'; import type { EntityQueryContext } from './EntityQueryContext.ts'; import type { FieldTransformerMap } from './internal/EntityFieldTransformationUtils.ts'; import type { IEntityLoadKey, IEntityLoadValue } from './internal/EntityLoadInterfaces.ts'; export declare const RESERVED_ENTITY_COUNT_QUERY_ALIAS = "__entity_count__"; /** * A database adapter is an interface by which entity objects can be * fetched, inserted, updated, and deleted from a database. This base class * handles all entity field transformation. Subclasses are responsible for * implementing database-specific logic for a type of database. */ export declare abstract class EntityDatabaseAdapter, TIDField extends keyof TFields> { protected readonly entityConfiguration: EntityConfiguration; protected readonly fieldTransformerMap: FieldTransformerMap; constructor(entityConfiguration: EntityConfiguration); /** * Transformer definitions for field types. Used to modify values as they are read from or written to * the database. Override in concrete subclasses to change transformation behavior. * If a field type is not present in the map, then fields of that type will not be transformed. */ protected abstract getFieldTransformerMap(): FieldTransformerMap; /** * Fetch many objects where key is one of values. * * @param queryContext - query context with which to perform the fetch * @param key - load key being queried * @param values - load values being queried * @returns map from value to objects that match the query for that value */ fetchManyWhereAsync, TSerializedLoadValue, TLoadValue extends IEntityLoadValue>(queryContext: EntityQueryContext, key: TLoadKey, values: readonly TLoadValue[]): Promise[]>>; protected abstract fetchManyWhereInternalAsync(queryInterface: any, tableName: string, tableColumns: readonly string[], tableTuples: (readonly any[])[]): Promise; /** * Fetch one objects where key is equal to value, null if no matching object exists. * Returned object is not guaranteed to be deterministic. Most concrete implementations will implement this * with a "first" or "limit 1" query. * * @param queryContext - query context with which to perform the fetch * @param key - load key being queried * @param value - load value being queried * @returns object that matches the query for the value */ fetchOneWhereAsync, TSerializedLoadValue, TLoadValue extends IEntityLoadValue>(queryContext: EntityQueryContext, key: TLoadKey, value: TLoadValue): Promise | null>; protected abstract fetchOneWhereInternalAsync(queryInterface: any, tableName: string, tableColumns: readonly string[], tableTuple: readonly any[]): Promise; /** * Insert an object. * * @param queryContext - query context with which to perform the insert * @param object - the object to insert * @returns the inserted object */ insertAsync(queryContext: EntityQueryContext, object: Readonly>): Promise>; protected abstract insertInternalAsync(queryInterface: any, tableName: string, object: object): Promise; /** * Update an object. * * @param queryContext - query context with which to perform the update * @param idField - the field in the object that is the ID * @param id - the value of the ID field in the object * @param object - the object to update */ updateAsync(queryContext: EntityQueryContext, idField: K, id: any, object: Readonly>): Promise; protected abstract updateInternalAsync(queryInterface: any, tableName: string, tableIdField: string, id: any, object: object): Promise<{ updatedRowCount: number; }>; /** * Delete an object by ID. * * @param queryContext - query context with which to perform the deletion * @param idField - the field in the object that is the ID * @param id - the value of the ID field in the object */ deleteAsync(queryContext: EntityQueryContext, idField: K, id: any): Promise; protected abstract deleteInternalAsync(queryInterface: any, tableName: string, tableIdField: string, id: any): Promise; }