dynamodb-toolbox
Version:
Lightweight and type-safe query builder for DynamoDB and TypeScript.
16 lines (15 loc) • 545 B
JavaScript
import { $SUM } from '../../symbols/index.js';
import { pathTokens, refOrValueTokens } from './utils.js';
export const expressSumUpdate = (value, path, state) => {
/**
* @debt type "Fix this cast"
*/
const [left, right] = value[$SUM];
let setExpression = pathTokens(path, 's', state);
setExpression += ' = ';
setExpression += refOrValueTokens(left, 's', state);
setExpression += ' + ';
setExpression += refOrValueTokens(right, 's', state);
state.setExpressions.push(setExpression);
return state;
};