import type { ExtraOptions, IdValue, Querier, Query, QueryConflictPaths, QueryOne, QueryOptions, QuerySearch, QuerySelect, QueryUpdateResult, RawRow, RelationKey, Type, UpdatePayload } from '../type/index.js'; import { LoggerWrapper } from '../util/index.js'; /** * Base class for all database queriers. * It provides a standardized way to execute tasks serially to prevent race conditions on database connections. */ export declare abstract class AbstractQuerier implements Querier { readonly extra?: ExtraOptions | undefined; /** * Internal promise used to queue database operations. * This ensures that each operation is executed serially, preventing race conditions * and ensuring that the database connection is used safely across concurrent calls. */ private taskQueue; protected readonly logger: LoggerWrapper; constructor(extra?: ExtraOptions | undefined); /** * Resolves entity from either a separate argument or from $entity field in query. * @param entityOrQuery - Entity class or query object with $entity * @param maybeQuery - Query object if entity was passed separately * @returns Tuple of [entity, query] */ protected resolveEntityAndQuery(entityOrQuery: Type | (QuerySearch & { $entity: Type; }), maybeQuery?: QuerySearch): [Type, QuerySearch]; findOneById(entity: Type, id: IdValue, q?: QueryOne): Promise; /** * Find a single record matching the query. * Supports both entity-as-argument and entity-as-field patterns. */ findOne(entity: Type, q: QueryOne): Promise; findOne(q: QueryOne & { $entity: Type; }): Promise; /** * Find multiple records matching the query. * Supports both entity-as-argument and entity-as-field patterns. */ findMany(entity: Type, q: Query): Promise; findMany(q: Query & { $entity: Type; }): Promise; protected abstract internalFindMany(entity: Type, q: Query): Promise; /** * Find multiple records and return both the records and total count. * Supports both entity-as-argument and entity-as-field patterns. */ findManyAndCount(entity: Type, q: Query): Promise<[E[], number]>; findManyAndCount(q: Query & { $entity: Type; }): Promise<[E[], number]>; /** * Count records matching the query. * Supports both entity-as-argument and entity-as-field patterns. */ count(entity: Type, q: QuerySearch): Promise; count(q: QuerySearch & { $entity: Type; }): Promise; protected abstract internalCount(entity: Type, q: QuerySearch): Promise; insertOne(entity: Type, payload: E): Promise>; insertMany(entity: Type, payload: E[]): Promise[]>; protected abstract internalInsertMany(entity: Type, payload: E[]): Promise[]>; updateOneById(entity: Type, id: IdValue, payload: UpdatePayload): Promise; updateMany(entity: Type, q: QuerySearch, payload: UpdatePayload): Promise; protected abstract internalUpdateMany(entity: Type, q: QuerySearch, payload: UpdatePayload): Promise; abstract upsertOne(entity: Type, conflictPaths: QueryConflictPaths, payload: E): Promise; abstract upsertMany(entity: Type, conflictPaths: QueryConflictPaths, payload: E[]): Promise; deleteOneById(entity: Type, id: IdValue, opts?: QueryOptions): Promise; /** * Delete records matching the query. * Supports both entity-as-argument and entity-as-field patterns. */ deleteMany(entity: Type, q: QuerySearch, opts?: QueryOptions): Promise; deleteMany(q: QuerySearch & { $entity: Type; }, opts?: QueryOptions): Promise; protected abstract internalDeleteMany(entity: Type, q: QuerySearch, opts?: QueryOptions): Promise; saveOne(entity: Type, payload: E): Promise>; saveMany(entity: Type, payload: E[]): Promise[]>; protected fillToManyRelations(entity: Type, payload: E[], select: QuerySelect): Promise; protected putChildrenInParents(parents: E[], children: RawRow[], parentIdKey: keyof E & string, referenceKey: string, relKey: keyof E & string): void; protected insertRelations(entity: Type, payload: E[]): Promise; protected updateRelations(entity: Type, q: QuerySearch, payload: UpdatePayload): Promise; protected deleteRelations(entity: Type, ids: IdValue[], opts?: QueryOptions): Promise; protected saveRelation(entity: Type, payload: E, relKey: RelationKey, isUpdate?: boolean): Promise; abstract readonly hasOpenTransaction: boolean; transaction(callback: () => Promise): Promise; /** * Emit a lifecycle hook event for the given entity. * Fires global listeners first, then entity-level hooks. */ private emitHook; releaseIfFree(): Promise; /** * Schedules a task to be executed serially in the querier instance. * This is used by the @Serialized decorator to protect database-level operations. * * @param task - The async task to execute. * @returns A promise that resolves with the task's result. */ protected serialize(task: () => Promise): Promise; abstract beginTransaction(): Promise; abstract commitTransaction(): Promise; abstract rollbackTransaction(): Promise; protected abstract internalRelease(): Promise; release(): Promise; } //# sourceMappingURL=abstractQuerier.d.ts.map