Fire Beast

How to remove all data from Firestore

The simplest way to remove all documents from Firestore, it to use the Firebase command-line tools:

# Install the command-line tools if you didn't do it yet
npm install -g firebase-tools

# Run in the project directory:
firebase firestore:delete --all-collections

# On in any place specifing the project ID:
firebase firestore:delete --all-collections --project PROJECT_ID

If you want to clear Firestore collections programmatically, you can use the same command directly from the npm module:

import * as tools from 'firebase-tools'

// Firebase Functions Node.js v8 runtime sets GCP_PROJECT,
// while v10 uses depricated GCLOUD_PROJECT.
// When you run this code locally, pass GCP_PROJECT environment variable.
const project = process.env.GCP_PROJECT || process.env.GCLOUD_PROJECT

// In the Firebase Functions environment, you won't need to authorize
// the function call, so you can skip passing the token.
// When you run it locally, use `firebase login:ci` to generate the token and
// then pass it as an environment variable.
const token = process.env.TOKEN

  .delete(null, {
    allCollections: true,
    yes: true,
    // Omit if you run this code in Firebase Functions environment
  .then(() => console.log('Done!'))
  .catch(err => {