amazon-web-services - AWS DocumentDB 中的删除操作

标签 amazon-web-services aws-documentdb aws-documentdb-mongoapi

我对删除 AWS DocumentDB 中的数据有疑问。

我使用 PuTTY 连接到 EC2 实例,并使用 mongo shell 命令连接我的文档数据库。

我检查了 AWS DocumentDB 文档,但找不到如何删除一个集合中的单个数据或整个数据。例如我说:

rs0:PRIMARY> show databases
gg_events_document_db  0.000GB
rs0:PRIMARY> use gg_events_document_db
switched to db gg_events_document_db
rs0:PRIMARY> db.data_collection.find({"Type": "15"})
{"Type" : "15", "Humidity" : "14.3%"}

现在我找到了数据,我想删除它。我需要运行什么查询?

或者如果我想删除集合中的所有数据怎么办?在不删除我的收藏的情况下我该怎么做?

可能我问的是非常基本的问题,但我自己找不到这样的查询。

如果 AWS DocumentDB 中经验丰富的人员可以帮助我或分享一些资源,我将非常高兴。

非常感谢🙌

最佳答案

Amazon DocumentDB 与 3.6 和 4.0 的 MongoDB API 兼容。也就是说,可以使用相同的 API 来满足此需求。关于:

Or what if I want to delete all data in the collection? Without deleting my collection how can I do it?

你可以使用:

db.data_collection.drop()

关于amazon-web-services - AWS DocumentDB 中的删除操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65307999/

相关文章:

amazon-web-services - 无法使用 MongoDB Compass 连接到 AWS Documentdb。没有选项可以传递 sslInvalidHostName

mongodb - 从 AWS Glue 连接到 DocumentDB

postgresql - 在 AWS-RDS 中创建 Postgres 事件触发器

amazon-web-services - CloudFormation - 从 Lambda 代码访问参数

shell - 如何使用 AWS CLI 在多个 EC2 实例上运行 shell 脚本?

amazon-web-services - 无法从我的 ubuntu EC2 机器连接到 AWS DocumentDB

aws-documentdb-mongoapi - 复合索引的多个字段不能是数组

scala - 适用于 Amazon DocumentDB 的兼容 Scala 驱动程序

amazon-web-services - docker 服务更新: "image could not be accessed on a registry to record it' s digest"