【发布时间】:2018-03-13 20:49:56
【问题描述】:
我正在尝试编写一个 lambda 函数来将新数据添加到 DynamoDB 表中。 从阅读文档:
http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB/DocumentClient.html#put-property PUT 方法:“创建新项目,或通过委托给 AWS.DynamoDB.putItem() 将旧项目替换为新项目。”
除了在“放置”之前检查对象之外,是否有设置或标志在尝试 PUT 时使对象存在失败?
我可以看到
params -> Expected -> Exists (Bool)
但看不到任何有关此功能的文档。
防止项目覆盖的最佳架构(或禁食)是什么?
Query the table first and if no item exists then add the item
或
Attempt to insert the item and on failure because of duplicate entry report this back? (Is there a way to prevent item overwrite?)
【问题讨论】:
标签: amazon-web-services lambda amazon-dynamodb