kysely-mapper
Version:
Flexible Kysely-based utility for mapping between tables and objects
39 lines • 2.29 kB
TypeScript
import { Kysely, SelectQueryBuilder } from 'kysely';
import { ParametersObject } from 'kysely-params';
import { SelectionColumn } from '../lib/type-utils.js';
import { ParameterizableMappingQuery } from './parameterizable-query.js';
import { SelectTransform } from '../mappers/table-mapper-transforms.js';
/**
* Compiling mapping query for selecting rows from a database table.
*/
export declare class CompilingMappingSelectQuery<DB, TB extends keyof DB & string, SelectedColumns extends Readonly<SelectionColumn<DB, TB>[]> | ['*'], SelectedObject, QB extends SelectQueryBuilder<DB, TB, any>, Parameters extends ParametersObject<Parameters>> implements ParameterizableMappingQuery {
#private;
readonly db: Kysely<DB>;
protected readonly transforms: Readonly<SelectTransform<DB, TB, SelectedColumns, SelectedObject>>;
constructor(db: Kysely<DB>, qb: QB, transforms: Readonly<SelectTransform<DB, TB, SelectedColumns, SelectedObject>>);
/**
* Retrieves zero or more rows from the table, using `selectTransform`
* (if provided) to map the rows to objects of type `SelectedObject`.
* Accepts values for any parameters embedded in the query.
*
* On the first execution, compiles and discards the underlying Kysely
* query builder. Subsequent executions reuse the compiled query.
* @param params Record characterizing the parameter names and types.
* Pass in `{}` if the query has no parameters.
* @returns An array of objects for the selected rows, possibly empty.
*/
returnAll(params: Parameters): Promise<SelectedObject[]>;
/**
* Retrieves a single row from the table, using `selectTransform` (if
* provided) to map the row to an object of type `SelectedObject`.
* Accepts values for any parameters embedded in the query.
*
* On the first execution, compiles and discards the underlying Kysely
* query builder. Subsequent executions reuse the compiled query.
* @param params Record characterizing the parameter names and types.
* Pass in `{}` if the query has no parameters.
* @returns An object for the selected rows, or null if not found.
*/
returnOne(params: Parameters): Promise<SelectedObject | null>;
}
//# sourceMappingURL=compiling-select-query.d.ts.map