我正在尝试更新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
});
Run Code Online (Sandbox Code Playgroud)
它正在发挥作用.但我想设置更多的值(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
});
Run Code Online (Sandbox Code Playgroud)
DynamoDb可以在一个查询中支持多个操作吗?
not*_*est 46
请更改下面提到的更新表达式.它应该工作.
第二个":inc"和SET之间没有逗号.
UpdateExpression : "ADD past_visits :inc, past_chats :inc SET reset_time = :value",
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10621 次 |
| 最近记录: |