Firestore:文档有子项,必须指定 -r 或 --shallow

Firestore : Document has children, must specify -r or --shallow

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

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

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

再次尝试 - firebase firestore:delete product/1

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

请帮我看看,-r-shallow[=29是什么意思=]是什么意思?

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

两种都试过了 -

firebase firestore:delete -r <path>

deletes all the docs(deeply nested also) inside a collection

firebase firestore:delete -shallow <path>

deletes all docs (1 level) inside the collection, it just unlink the collection from children docs, path still exists to fetch deeply nested children.

要理解参数,您可以使用 --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,它将 删除有问题的文档,并且会完整保留所有子集合。