UNPKG

kysely-mapper

Version:

Flexible Kysely-based utility for mapping between tables and objects

20 lines 756 B
/** * Restrict the values of an object to the specified columns, requiring that * all of the specified columns be present in the object. * @param obj The object to restrict. * @param toColumns The columns to restrict the object to. * @returns A new object with only the specified columns. */ export function restrictValues(obj, toColumns) { const values = {}; for (const column of toColumns) { const value = obj[column]; // ensure the output of the applied transform works for the present query if (value === undefined) { throw Error(`Specified column '${column}' missing from values object`); } values[column] = value; } return values; } //# sourceMappingURL=restrict-values.js.map