DynamoDB 可以批量删除具有特定分区键的项目吗?
Can DynamoDB batch delete items that have a specific partition key?
我正在使用 AWS DynamoDB 编写 iOS 应用程序。我有 table 个笔记,每个笔记都与一个用户 ID 相关联,作为全局二级索引分区键。是否可以批量删除与特定用户ID关联的所有笔记?
据我了解,这是您的 table...
Notes Table: noteID (hash key), userID, [other attributes]
UserNotesGSI: userID (hash key), noteID (range key)
...并且您询问是否有办法删除 UserNotesGSI 中具有相同用户 ID 的所有行。
这目前不可能,因为您根本无法 write/delete 来自 GSI 的项目。根据您对主要 table (Notes
) 所做的更改,DynamoDB 会自动为您同步 GSI。更多详细信息 here。
如果您查看 BatchWriteItem and DeleteItem methods, you'll notice that you can only specify the table that you want to update/remove items from and not the index, as you can with the Query 方法。这进一步支持了我的回答。
我正在使用 AWS DynamoDB 编写 iOS 应用程序。我有 table 个笔记,每个笔记都与一个用户 ID 相关联,作为全局二级索引分区键。是否可以批量删除与特定用户ID关联的所有笔记?
据我了解,这是您的 table...
Notes Table: noteID (hash key), userID, [other attributes]
UserNotesGSI: userID (hash key), noteID (range key)
...并且您询问是否有办法删除 UserNotesGSI 中具有相同用户 ID 的所有行。
这目前不可能,因为您根本无法 write/delete 来自 GSI 的项目。根据您对主要 table (Notes
) 所做的更改,DynamoDB 会自动为您同步 GSI。更多详细信息 here。
如果您查看 BatchWriteItem and DeleteItem methods, you'll notice that you can only specify the table that you want to update/remove items from and not the index, as you can with the Query 方法。这进一步支持了我的回答。