我想删除 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/