This doesn't work. Is there another way to do this? cord is a list to which I want to add a map.
var params5 = {
TableName: 'rides',
Key: {
'rid': data2.Items[0].rid
},
UpdateExpression: 'add cord :x',
ExpressionAttributeValues: {
':x': [{date: secondStartDate.toString(), latitude: xcorpassed, longitude: ycorpassed}]
},
ReturnValues: 'UPDATED_NEW'
}
docClient.update(params5, function (err5, data5) { ... }
Instead of ADD, you could use SET with the list_append function (in general, AWS recommends using SET rather than ADD):
(NOTE: The list_append function name is case-sensitive)
var params = {
TableName: "rides",
Key: {
"rid": data2.Items[0].rid
},
UpdateExpression: "SET #c = list_append(#c, :vals)",
ExpressionAttributeNames: {
"#c": "cord"
},
ExpressionAttributeValues: {
":vals": [{date: secondStartDate.toString(), latitude: xcorpassed, longitude: ycorpassed}]
},
ReturnValues: "UPDATED_NEW"
}
docClient.update(params, function (err, data) {
if (err) console.log(err);
else console.log(data);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With