import { IdentifierSqlTokenType, sql } from 'slonik'; type Table = { table: string; fields: Record }; type FieldIdentifiers = { [key in Key]: IdentifierSqlTokenType; }; export const convertToIdentifiers = ( { table, fields }: T, withPrefix = false ) => ({ table: sql.identifier([table]), fields: Object.entries(fields).reduce( (previous, [key, value]) => ({ ...previous, [key]: sql.identifier(withPrefix ? [table, value] : [value]), }), // eslint-disable-next-line @typescript-eslint/prefer-reduce-type-parameter {} as FieldIdentifiers ), });