DynamoDB 更新项目多操作 [英] DynamoDB update Item multi action
本文介绍了DynamoDB 更新项目多操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试更新 DynamoDB 表中的项目:
I am trying to update an item in DynamoDB table:
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'):
It's working. But I want to set some more value (reset_time = :value') like this:
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 能否在一个查询中支持多项操作?
Can DynamoDb support multi action in one query ?
推荐答案
请按如下所述更改更新表达式.它应该可以工作.
Please change the update expression as mentioned below. It should work.
第二个 ":inc" 和 SET 之间没有逗号.
There is no comma between second ":inc" and SET.
UpdateExpression : "ADD past_visits :inc, past_chats :inc SET reset_time = :value",
这篇关于DynamoDB 更新项目多操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文