simpledb:覆盖一个项目并替换所有属性
如何覆盖一个项目并替换其所有属性。
例如,我有一个项目 A,具有以下属性
ItemA
AttrA = ValueA
AttrB = ValueB
现在我想使用以下属性更新 ItemA
ItemA(已更新)
AttrB = ValueB1
AttrC = ValueC
我正在使用 Java SDK。我不想删除该项目然后再创建它。目前,我正在使用 BatchPutAttributesRequest 重新创建项目,但令人惊讶的是,它不会删除更新项目中不存在的属性。
所以我最终得到 Item ItemA
AttrA
= ValueA
属性B = 值B1
属性C = 值C
How can I overwrite an item and replace all its attributes.
For eg., I have an item A, with following attributes
ItemA
AttrA = ValueA
AttrB = ValueB
now I want to update ItemA with the following attributes
ItemA(Updated)
AttrB = ValueB1
AttrC = ValueC
I am using the Java SDK. I don't want to delete the item and then create it. Currently, I am using BatchPutAttributesRequest to re-create the item but surprisingly, it doesn't delete the attributes that are not present in the updated item.
So I end up with the Item
ItemA
AttrA = ValueA
AttrB = ValueB1
AttrC = ValueC
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
BatchPutAttributesRequest 请求不会删除您未包含在请求中的现有属性。您需要通过指定要删除的属性列表向 Amazon SimpleDB 发送另一个请求 DeleteAttributesRequest。 BatchPutAttributesRequest 只能添加新属性或可以更新属性的现有值。
BatchPutAttributesRequest request does not delete existing Attribute that you had not included in your request. You need to send an another request DeleteAttributesRequest to Amazon SimpleDB by specifying list of Attributes that you wish to delete. BatchPutAttributesRequest can only add new Attribute or can update existing value of an attribute.