UNPKG

dynamodb-toolbox

Version:

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

16 lines (15 loc) 560 B
import { $SUBTRACT } from '../../symbols/index.js'; import { pathTokens, refOrValueTokens } from './utils.js'; export const expressSubtractUpdate = (value, path, state) => { /** * @debt type "Fix this cast" */ const [left, right] = value[$SUBTRACT]; let setExpression = pathTokens(path, 's', state); setExpression += ' = '; setExpression += refOrValueTokens(left, 's', state); setExpression += ' - '; setExpression += refOrValueTokens(right, 's', state); state.setExpressions.push(setExpression); return state; };