firebase - Firestore : Document has children, 必须指定 -r 或 --shallow

标签 firebase google-cloud-firestore firebase-cli

我想删除 firestore 中的整个集合。

我使用了 firebase 命令 - firebase firestore:delete Product/

Error: Must pass recursive or shallow option when deleting a collection.

再次尝试 - firebase firestore:删除产品/1

Error: Document has children, must specify -r or --shallow.

请帮我知道-r-shallow是什么意思?

我应该选择哪个选项来使用 firebase 命令批量删除整个集合?我需要删除集合中的整个文档。

最佳答案

要理解这些参数,您可以使用--help:

$ firebase firestore:delete --help

  Usage: firestore:delete [options] [path]

  Delete data from Cloud Firestore.


  Options:

    -r, --recursive    Recursive. Delete all documents and subcollections. Any action which would result in the deletion of child documents will fail if this argument is not passed. May not be passed along with --shallow.
    --shallow          Shallow. Delete only parent documents and ignore documents in subcollections. Any action which would orphan documents will fail if this argument is not passed. May not be passed along with -r.
    --all-collections  Delete all. Deletes the entire Firestore database, including all collections and documents. Any other flags or arguments will be ignored.
    -y, --yes          No confirmation. Otherwise, a confirmation prompt will appear.
    -h, --help         output usage information

这里的两个选项是-r(递归)或--shallow

如果在删除文档时传递-r,那么它也会删除该文档的所有子集合以及子集合的所有子集合等。

如果您传递--shallow,它将删除有问题的文档,并完整保留所有子集合。

关于firebase - Firestore : Document has children, 必须指定 -r 或 --shallow,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49103017/

相关文章:

firebase-cli - 如何查看当前使用 CLI 登录的 firebase 帐户?

Firebase 部署的 URL 不起作用?

firebase - Flutter Firestore 缓存流

Android Firestore通过文档id获取字段值

firebase - 比较 firestore 中的资源和请求资源

java - Android - 如何等待 SnapshotListener 完成?

android - 如何正确使用 Firebase-Analytics 进行 A/B 测试?

java - 从外部存储读取数据库文件

javascript - 在 Firebase Firestore 中,我想使用 orderBy 两次。是否需要创建索引来加快查询速度?

firebase - 安装了多个版本的 Firebase - 我该使用哪个?