我正在使用 dynamodb 的 docker 映像。每当我尝试对表执行更新操作时,它都会使用相同的主键创建一条新记录,而不是更新现有的记录。完成此操作后,我无法删除该行或对其执行任何操作。当前唯一有效的解决方案是删除旧记录并创建新记录。
我的表定义是:
{
TableName: "commission",
KeySchema: [
{ AttributeName: "public_key", KeyType: "HASH" }, //Partition key
],
AttributeDefinitions: [{ AttributeName: "public_key", AttributeType: "S" }],
ProvisionedThroughput: {
ReadCapacityUnits: 5,
WriteCapacityUnits: 5,
},
}
更新使用 NoSQL Workbench 生成的查询:
{
TableName: "commission",
Key: {
"public_key": publickey
},
UpdateExpression: "set commission = :commission , commisison_limit = :commissionlimit ",
ExpressionAttributeValues: {
":commission": commission,
":commissionlimit": commissionlimit
},
ReturnValues: "UPDATED_NEW"
}