UNPKG

dynamodb-toolbox

Version:

Lightweight and type-safe query builder for DynamoDB and TypeScript.

15 lines (14 loc) 523 B
import { isFunction } from '../../../../utils/validation/isFunction.js'; export const getDefaultsDTO = (schema) => { const defaultsDTO = {}; for (const mode of ['keyDefault', 'putDefault', 'updateDefault']) { const modeDefault = schema.props[mode]; if (modeDefault === undefined) { continue; } defaultsDTO[mode] = isFunction(modeDefault) ? { defaulterId: 'custom' } : { defaulterId: 'value', value: modeDefault }; } return defaultsDTO; };