import { SqlQuery } from './sql';
import type { BaseDatabase } from './database';
import { EntityClass } from './metadata';
import type { DatabaseSession } from './session';
type Direction = 'asc' | 'desc';
type DirectionInput = Direction | 'ASC' | 'DESC' | 1 | -1;
export type FilterValue = unknown | {
    $in?: unknown[];
    $nin?: unknown[];
    $ne?: unknown;
    $gt?: unknown;
    $gte?: unknown;
    $lt?: unknown;
    $lte?: unknown;
    $like?: unknown;
    $notLike?: unknown;
};
export type FilterRecord = Record<string, FilterValue>;
export type FilterQuery<T extends object = object> = Partial<Record<keyof T, FilterValue>> & FilterRecord;
export type PatchOperator = {
    $inc?: number;
};
export type PatchValue<T> = T | PatchOperator;
export type PatchRecord<T extends object> = Partial<{
    [K in keyof T]: PatchValue<T[K]>;
}> & Record<string, unknown>;
export interface QueryMutationResult {
    affectedRows: number;
    readonly modified: number;
    primaryKeys: Record<string, unknown>[];
}
export declare class QueryBuilder<T extends object> {
    private db;
    private Entity;
    private session?;
    private filters;
    private selected?;
    private aggregateSelections;
    private order;
    private limitValue?;
    private offsetValue?;
    private lockForUpdate;
    constructor(db: BaseDatabase, Entity: EntityClass<T>, session?: DatabaseSession | undefined);
    filter(filter: FilterRecord): this;
    filterField(field: keyof T | string, value: FilterValue): this;
    select(...fields: string[]): this;
    withMax(field: keyof T | string): this;
    orderBy(field: string, direction?: DirectionInput): this;
    sort(field: string | Record<string, DirectionInput>, direction?: DirectionInput): this;
    limit(limit: number): this;
    offset(offset: number): this;
    skip(offset: number): this;
    /** Locks selected rows until the active transaction completes. */
    forUpdate(): this;
    find(): Promise<T[]>;
    findField<K extends keyof T>(field: K): Promise<T[K][]>;
    findOneFieldOrUndefined<K extends keyof T>(field: K): Promise<T[K] | undefined>;
    findOneField<K extends keyof T>(field: K): Promise<T[K]>;
    findOneOrUndefined(): Promise<T | undefined>;
    findOne(): Promise<T>;
    has(): Promise<boolean>;
    count(): Promise<number>;
    patchMany(patch: PatchRecord<T>): Promise<QueryMutationResult>;
    patchOne(patch: PatchRecord<T>): Promise<QueryMutationResult>;
    deleteMany(): Promise<QueryMutationResult>;
    deleteOne(): Promise<QueryMutationResult>;
    toSelectSql(): SqlQuery;
    toCountSql(): SqlQuery;
    private buildSelectSql;
    private renderWhere;
    private findMutationTargets;
    private hydrate;
    private resolveColumnName;
    private resolveColumn;
    private renderPatchSet;
    private requirePrimaryKeyFilter;
    private assertObservedPrimaryKeyIsStable;
    private withTemporaryLimit;
    private runMutation;
    private runRead;
}
export {};
//# sourceMappingURL=query.d.ts.map