@rtorcato/db-common / pick
Function: pick()
pick(
obj,keys):InsertShape
Defined in: pick.ts:16
Pick keys off an object into parallel columns/values arrays for an
INSERT, dropping keys whose value is undefined. Write-side companion to
where. A null is kept (map it to a NULL column); only undefined — a
key the caller left unset — is skipped.
pick({ name: 'Ada', email: undefined, active: null }, ['name', 'email', 'active']) // → { columns: ['name', 'active'], values: ['Ada', null] }
Parameters
obj
Record<string, unknown>
keys
string[]