const AWS = require('aws-sdk');
const docClient = new AWS.DynamoDB.DocumentClient();
const params = {
TableName: 'table-name',
Key: {
'id': 'object-id'
},
UpdateExpression: 'set property_name = :value', // 更新表达式
ExpressionAttributeValues: {
':value': 'new-value' // 表达式属性值
}
};
docClient.update(params, function(err, data) {
if (err) {
console.error('Error: ', err);
} else {
console.log('Success: ', data);
}
});
其中,参数说明如下: