kysely-mapper
Version:
Flexible Kysely-based utility for mapping between tables and objects
42 lines • 2.27 kB
TypeScript
import { DeleteQueryBuilder, DeleteResult, Kysely } from 'kysely';
import { ParametersObject } from 'kysely-params';
import { ParameterizableMappingQuery } from './parameterizable-query.js';
import { CompilingMappingDeleteQuery } from './compiling-delete-query.js';
import { CountTransform } from '../mappers/table-mapper-transforms.js';
/**
* Mapping query for deleting rows from a database table.
*/
export declare class MappingDeleteQuery<DB, TB extends keyof DB & string, QB extends DeleteQueryBuilder<DB, TB, DeleteResult>, ReturnCount> implements ParameterizableMappingQuery {
protected readonly db: Kysely<DB>;
protected readonly qb: QB;
protected readonly transforms: Readonly<CountTransform<ReturnCount>>;
constructor(db: Kysely<DB>, qb: QB, transforms: Readonly<CountTransform<ReturnCount>>);
/**
* Returns a compiling query that can be executed multiple times with
* different parameters (if any parameters were provided), but which only
* compiles the underlying Kysely query builder on the first execution.
* Frees the query builder on the first execution to reduce memory usage.
* @typeParam Parameters Record characterizing the parameter names and
* types that were previously embedded in the query, if any.
* @returns A compiling delete query.
*/
compile<Parameters extends ParametersObject<Parameters> = {}>(): CompilingMappingDeleteQuery<DB, TB, QB, ReturnCount, Parameters>;
/**
* Runs the query, returning the number of rows deleted, converted to
* the required client representation.
* @returns Number of rows deleted, in client-requested representation.
*/
returnCount(): Promise<ReturnCount>;
/**
* Modifies the underlying Kysely query builder.
* @param factory A function that takes the current query builder and
* returns a new query builder.
*/
modify<NextQB extends DeleteQueryBuilder<DB, any, DeleteResult>>(factory: (qb: QB) => NextQB): MappingDeleteQuery<DB, TB, NextQB, ReturnCount>;
/**
* Runs the query, deleting the indicated rows, returning nothing.
* @returns `true` if any rows were deleted, `false` otherwise.
*/
run(): Promise<boolean>;
}
//# sourceMappingURL=delete-query.d.ts.map