我正在尝试更新DynamoDB表中的项目:
var params = {
TableName: 'User',
Key: {
id: 'b6cc8100-74e4-11e6-8e52-bbcb90cbdd26',
},
UpdateExpression: 'ADD past_visits :inc, past_chats :inc',
ExpressionAttributeValues: {
':inc': 1
},
ReturnValues: 'ALL_NEW'
};
docClient.update(params, function(err, data) {
if (err) ppJson(err); // an error occurred
else ppJson(data); // successful response
});
工作正常但是我想像这样设置更多的值(reset_time =:value'):
var params = {
TableName: 'User',
Key: {
id: 'b6cc8100-74e4-11e6-8e52-bbcb90cbdd26',
},
UpdateExpression: 'ADD past_visits :inc, past_chats :inc, SET reset_time = :value',
ExpressionAttributeValues: {
':inc': 1,
':value': 0
},
ReturnValues: 'ALL_NEW'
};
docClient.update(params, function(err, data) {
if (err) ppJson(err); // an error occurred
else ppJson(data); // successful response
});
DynamoDb可以在一个查询中支持多 Action 吗?
最佳答案
请如下所述更改更新表达式。它应该工作。
第二个“:inc”和SET之间没有逗号。
UpdateExpression : "ADD past_visits :inc, past_chats :inc SET reset_time = :value",
关于amazon-dynamodb - DynamoDB更新项目多操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39382050/