Firestore の 初期化 リセット方法(コレクションの削除)
はじめに
Firestoreをいろいろいじっていると個別のコレクションの削除や全部初期化をしたい場合があります。その場合は、Firebase CLIを利用すると簡単に操作することができます。
手順
Install Command
sudo npm install -g firebase-tools
Login
firebase login
Check if the command works
$ firebase projects:list
✔ Preparing the list of your Firebase projects
No projects found.
Delete Collections and Docs in project-aaa
$ firebase firestore:delete --all-collections -y --project project-aaa
Deleting the following collections: cities, citiest0921, citiest0922, citiest0923, users
Deleted 3 docs (Infinity docs/s)
Deleted 5 docs (29 docs/s)
Deleted 6 docs (19 docs/s)
Deleted 11 docs (30 docs/s)
オプション一覧
> firebase firestore:delete --help
Usage: firebase firestore:delete [options] [path]
Delete data from Cloud Firestore.
Options:
-r, --recursive Recursive. Delete all documents and subcollections at and under the specified level. May not be passed along with --shallow.
--shallow Shallow. Delete only documents at the specified level and ignore documents in subcollections. This action can potentially orphan documents nested in subcollections. 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
参考文献
> firebase firestore:delete --help
Usage: firebase firestore:delete [options] [path]
Delete data from Cloud Firestore.
Options:
-r, --recursive Recursive. Delete all documents and subcollections at and under the specified level. May not be passed along with --shallow.
--shallow Shallow. Delete only documents at the specified level and ignore documents in subcollections. This action can potentially orphan documents nested in subcollections. 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
Author And Source
この問題について(Firestore の 初期化 リセット方法(コレクションの削除)), 我々は、より多くの情報をここで見つけました https://qiita.com/ekzemplaro/items/8af83953756980159f42著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .