I have a dynamoDB table that has a list of strings as an attribute of a User item (AssignedPractices):
{
"UserID": "2291b7bf-90a4-439e-872e-1bf6e8112a59",
"Address": "?",
"AssignedPractices": [
"50575950-d932-48bc-8f27-eb476408ef91",
"f4495bed-faf7-44e6-9f76-08fc0818b8f3"
],
"Name": "John Doe",
"Phone": "?",
}
In dynamo it looks like this:
"AssignedPractices": {
"L": [
{
"S": "50575950-d932-48bc-8f27-eb476408ef91"
},
{
"S": "f4495bed-faf7-44e6-9f76-08fc0818b8f3"
}
]
},
I'm trying to update this list using a graphQL mutation. Since this is going to be a short list of strings, in order to not deal with insertions/removals, I just want to overwrite it.
This is what I've attempted, but documentClient just bails on me .. no error or exception.
const params = {
TableName: tableName,
Key: { [primaryKey]: primaryKeyValue },
UpdateExpression: `set ${updateKey} = :updateValue`,
ExpressionAttributeValues: {
':updateValue': updateValue,
},
};
console.log('[update] params =', params);
try {
const result = await documentClient.update(params).promise();
console.log('[update] result =', result);
return 1;
} catch (err) {
console.log('[update] : error', err);
return 0;
}
I see in CloudWatch that it did get the list of strings:
INFO [update] params = {
TableName: 'users',
Key: { UserID: '2291b7bf-90a4-439e-872e-1bf6e8112a59' },
UpdateExpression: 'set AssignedPractices = :updateValue',
ExpressionAttributeValues: {
':updateValue': [
'50575950-d932-48bc-8f27-eb476408ef91',
'f4495bed-faf7-44e6-9f76-08fc0818b8f3',
'da9e34b1-8bad-4f2d-b0eb-637dbc6c8ef0'
]
}
}
But nothing after that, and the list obviously didn't update. Feels to me my UpdateExpression is not correct, but not sure how to make it work.