【发布时间】:2016-09-08 03:17:49
【问题描述】:
我正在尝试更新 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 能否在一个查询中支持多项操作?
【问题讨论】:
-
如果有用,我可以要求接受答案吗?谢谢!
标签: amazon-dynamodb