UNPKG

kysely-mapper

Version:

Flexible Kysely-based utility for mapping between tables and objects

36 lines 1.7 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SubsettingMappingUpdateQuery = void 0; const update_query_js_1 = require("./update-query.js"); const compiling_update_query_js_1 = require("./compiling-update-query.js"); const restrict_values_js_1 = require("../lib/restrict-values.js"); /** * Mapping query for updating rows into a database table, * updating a specified subset of the updateable columns. */ class SubsettingMappingUpdateQuery extends update_query_js_1.MappingUpdateQuery { constructor(db, qb, columnsToUpdate, transforms, returnColumns) { super(db, qb, transforms, returnColumns); this.columnsToUpdate = columnsToUpdate; } /** * 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 update query. */ compile() { return new compiling_update_query_js_1.CompilingMappingUpdateQuery(this.db, this.qb, this.columnsToUpdate, this.transforms, this.returnColumns); } getUpdateColumns() { return this.columnsToUpdate; } setColumnValues(qb, obj) { return qb.set((0, restrict_values_js_1.restrictValues)(obj, this.columnsToUpdate)); } } exports.SubsettingMappingUpdateQuery = SubsettingMappingUpdateQuery; //# sourceMappingURL=subsetting-update-query.js.map