删除所有具有相同哈希键的项目

删除所有具有相同哈希键的项目

本文介绍了DynamoDb:删除所有具有相同哈希键的项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请考虑下表:

Table (documentId : Hash Key, userId: Range Key)

如何编写代码以删除所有具有相同 documentId ,最好不要检索这些项目。

How can I write a code to delete all the items having the same documentId and preferably without retrieving the items.

推荐答案

当前,您不能仅通过传递哈希键来删除所有项目,即删除一个需要散列+范围的项目,因为这就是它的独特之处。

Currently, You cannot delete all the items just by passing the Hash key, to delete an item it requires Hash + Range because that's what makes it unique.

You have to know both your (hash + range) to delete the item.

编辑:这是DynamoDB文档 http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_DeleteItem.html#API_DeleteItem_RequestSyntax >

Here is the reference link from DynamoDB documentation http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_DeleteItem.html#API_DeleteItem_RequestSyntax

请阅读 KEY的说明,该说明明确指出我们必须同时传递Hash(分区键)和Range(排序键)才能删除该项目。

Please read the explanation of the "KEY" which clearly says that we must pass both Hash (Partition Key) and Range (Sort Key) to delete the item.

这篇关于DynamoDb:删除所有具有相同哈希键的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!