@tridnguyen/firestore

2.1.1 • Public • Published

@tridnguyen/firestore

Simple wrapper around @google-cloud/firestore package

Environment variables

This package assumes the following environment variables to always be set:

FIRESTORE_PROJECT_ID=<your-google-cloud-project-id>
GOOGLE_APPLICATION_CREDENTIALS=<path-to-service-account-json-file>
# instructions for service account
# https://cloud.google.com/docs/authentication/getting-started

Delete collection

The main reason for this package to exist is the implementation of the deleteCollection method, which retrieve all documents within the collection or subcollection and delete them, in batches. Inspired by https://firebase.google.com/docs/firestore/manage-data/delete-data#collections.

const { firestore } = require('@tridnguyen/firestore');

const myDocRef = firestore.doc('docs/my-doc');

firestore.deleteCollection('docs/my-doc/sub-collection')
  .then(() => {
    return myDocRef.delete();
  });

Readme

Keywords

Package Sidebar

Install

npm i @tridnguyen/firestore

Weekly Downloads

1

Version

2.1.1

License

ISC

Unpacked Size

3.2 kB

Total Files

3

Last publish

Collaborators

  • tridnguyen