Skip to content
Branch: master
Find file History
Type Name Latest commit message Commit time
Failed to load latest commit information.
functions Firestore Numeric Transforms (#34) Mar 21, 2019
public Firestore server-side deletes solution (#17) Sep 24, 2018

Solution: Recursive Deletes

This solution shows how to write a Cloud Function that deletes data in Cloud Firestore and securely call this function from your mobile app or website.


On your development machine

  1. Set up your Firebase project in the solution-deletes directory by running firebase init. This solution uses both Firebase Hosting and Cloud Functions for Firebase.
  2. Generate a Firebase token using the firebase login:ci command.
  3. Add the token to your Cloud Functions runtime configuration using the following command:
    firebase functions:config:set fb.token="YOUR_TOKEN_HERE"
  4. Run firebase deploy --only functions to deploy the Cloud Functions.
  5. Run firebase serve --only hosting to run a local version of the application.

In your browser

  1. Enable the Identity and Access Management (IAM) API on your project in the Google Cloud console by visiting:
  2. In the IAM page of the Google Cloud console, find the service account called the "App Engine default service account" and grant it the "Service Account Token Creator" role.


  1. Visit http://localhost:5000 to see the running sample.
  2. Click the SIGN IN button. This will call the Cloud Function you deployed to generate a custom sign in token, and then use that token to sign in on the client.
  3. Enter the path of the document or collection you would like to delete, for example things/thing1, then click DELETE.
You can’t perform that action at this time.