根据DynamoDB中的全局二级索引删除多个项目 [英] Deleting multiple items based on global secondary index in DynamoDB

查看:16
本文介绍了根据DynamoDB中的全局二级索引删除多个项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个现有的表,它有两个字段 - 主键和全局二级索引:

I have an existing table which has two fields - primary key and a global secondary index:

----------------------------
primary key | attributeA(GSI)
----------------------------
1           | id1
2           | id1
3           | id2
4           | id2
5           | id1

既然将attributeA作为全局二级索引,我可以通过为全局二级索引指定一个值来删除所有项目吗?即我想删除属性 A 为 id1 的所有记录 - 这在 Dynamo 中是否可行?

Since having the attributeA as a global secondary index, can I delete all items by specifying a value for the global secondary index? i.e I want to delete all records with the attributeA being id1 - Is this possible in Dynamo?

Dynamo 提供了有关删除索引本身的文档,但没有具体说明我们是否可以使用 GSI 删除多个项目

Dynamo provides documentation about deleting the index itself, but not specifically if we can use the GSI to delete multiple items

推荐答案

到目前为止,您不能仅通过传递非键属性或 GSI 键来删除项目.

As of now, you cannot delete an item just by passing Non-key attributes or GSI keys.

最简单的方法是查询 GSI 并获取 primaryKey(表的哈希键)并在下一个请求中删除.

The simplest way to do this is to Query GSI and get primaryKey(Hash key of the table) and Delete in next request.

如果你想做批量删除,你可以参考这个答案.

You can refer this answer if you want to do batchDeletion.

希望有帮助

这篇关于根据DynamoDB中的全局二级索引删除多个项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆