问题描述
默认情况下,如果具有指定索引的对象不存在,DynamoDB 将创建一个新条目.有没有办法阻止这种情况发生?我可以在更新之前在表中查询密钥,但最好在一个请求中完成所有操作.
By default DynamoDB will make a new entry if an object with the specified index doesn't exist. Is there a way to stop this from occurring? I could just query the table for the key before updating, but it would be nice to do it all in one request.
推荐答案
使用条件表达式 id = :id 其中 id 是属性名(或主键名您的情况)和 :id 是值(您要更新的项目的键).
Use conditional expression id = :id where id is the attribute name (or primary key name in your case) and :id is the value (key of the item you want to update).
条件表达式总是在任何写入之前进行评估.如果该表达式的计算结果不是 true(并且如果该键不存在或不同,则不会),它不会更新或放置新项目.
Conditional expression is always evaluated before any writing. If that expression doesn't evaluate to true (and it doesn't if that key doesn't exist or is different), it doesn't update or put a new item.
这篇关于DynamoDB:仅当它已经存在时才更新项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!



大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)