I have a table that has an attribute which is actually a JSON list.
var myItem = {
name: 'myname',
tasks: [
{ key1: 'value1', key2: 'value2' }
]
}
I put the myItem into the table like this, and this seems to work fine.
var params = {
TableName: 'runs',
Item: myItem
};
dynamodbDoc.put( params, ...
I then want to update the record to change the "tasks".
var newTasks = [
{ key1: 'newvalue1', key2: 'newvalue2' }
]
So I setup for an updateItem like this:
var params = {
TableName: 'runs',
Key: {
name: { S: 'myname' }
},
UpdateExpression: "SET #tasks = :tasks",
ExpressionAttributeNames: {
"#tasks": "tasks"
},
ExpressionAttributeValues: {
":tasks": newTasks
},
ReturnValues: 'ALL_NEW'
}
dynamodb.updateItem( params, ...
This fails by giving me UnexpectedParameter: Unexpected key '0' found in params.ExpressionAttributeValues[':tasks']
.
I've also tried
ExpressionAttributeValues: {
":tasks": { M: tasks }
},
And also...
ExpressionAttributeValues: {
":tasks": { L: tasks }
},
These don't work either. Obviously I'm missing something here.