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