I'm having trouble pushing an object into an array/Set the object into it as docs state in dynamodb. Getting the error:
Invalid UpdateExpression: Incorrect number of operands for operator or function; operator or function: if_not_exists, number of operands: 1
What am I doing wrong? I appreciate any help!
export async function postTrade(position) {
let params = {
Key: {
PK: 'stocks'
},
UpdateExpression: 'set #tickers = list_append(if_not_exists(#tickers))',
ExpressionAttributeNames: {
'#tickers': 'tickers'
},
ExpressionAttributeValues: {
':tickers': [position]
},
TableName: 'stockTable'
};
await docClient.update(params).promise();
}
Dynamo record
{
"PK": "stocks",
"tickers": [
]
}