import { Kysely, InsertQueryBuilder, InsertResult, Insertable } from 'kysely'; import { SelectionColumn } from '../lib/type-utils.js'; import { InsertTransforms } from '../mappers/table-mapper-transforms.js'; /** * Mapping query for inserting rows into a database table. */ export declare class MappingInsertQuery, InsertedObject, InsertReturnColumns extends Readonly[]> | ['*'], InsertReturn> { #private; protected readonly db: Kysely; protected readonly qb: QB; protected readonly transforms: Readonly>; protected readonly returnColumns: Readonly; constructor(db: Kysely, qb: QB, transforms: Readonly>, returnColumns: Readonly); /** * Modifies the underlying Kysely query builder. * @param factory A function that takes the current query builder and * returns a new query builder. */ modify>(factory: (qb: QB) => NextQB): MappingInsertQuery; /** * Inserts the provided objects into the table as rows, first transforming * them into rows via `insertTransform` (if defined). For each row inserted, * retrieves the columns specified in `returnColumns`, returning them to * the caller as `InsertReturn`, after transformation by * `insertReturnTransform`. If `returnColumns` is empty, returns `undefined`. * @returns If `returnColumns` is not empty, returns an array containing one * object for each inserted object; otherwise returns `undefined`. */ returnAll(objs: InsertedObject[]): Promise; /** * Inserts the provided object into the table as a row, first transforming * it into a row via `insertTransform` (if defined). Also retrieves the * columns specified in `returnColumns`, returning them to the caller as * `InsertReturn`, after transformation by `insertReturnTransform`. * If `returnColumns` is empty, returns `undefined`. * @returns If `returnColumns` is not empty, returns an object; * otherwise returns `undefined`. */ returnOne(obj: InsertedObject): Promise; /** * Runs the query, inserting rows into the table without returning any columns. * @param objOrObjs The object or objects to be inserted. * @returns Returns `true`; throws an exception on error. */ run(objOrObjs: InsertedObject | InsertedObject[]): Promise; /** * Returns an array of the columns to be inserted, with * `['*']` indicating that all columns will be inserted. * @returns An array of the columns to be inserted. */ protected getInsertColumns(): Readonly<(keyof Insertable & string)[]> | ['*']; /** * Returns a query builder for inserting rows into the table and * returning values, caching the query builder for future use. * @returns A query builder for inserting rows into the table and * returning values. */ protected getReturningQB(): InsertQueryBuilder; /** * Loads the objects to be inserted into the query builder. * @param qb The query builder to load the objects into. * @param objOrObjs The object or objects to be inserted. * @returns The query builder with the objects loaded. */ protected loadInsertedObjects(qb: InsertQueryBuilder, objOrObjs: InsertedObject | InsertedObject[]): InsertQueryBuilder; /** * Sets the values of the inserted columns. * @param qb The query builder to set the values into. * @param objOrObjs The object or objects of column-value pairs * to be inserted. */ protected setColumnValues(qb: InsertQueryBuilder, objOrObjs: Insertable | Insertable[]): InsertQueryBuilder; } //# sourceMappingURL=insert-query.d.ts.map