0.1.6 • Published 4 years ago

admin-utils-firestore v0.1.6

Weekly downloads
5
License
MIT
Repository
github
Last release
4 years ago

npm Travis NPM Code Style: Google

Helpers used for common admin task on Firestore databases.

Installation:

  • Install the package via:
$ npm install --save admin-utils-firestore
  • Init admin-utils-firestore via:
import {FirestoreAdminUtils} from 'admin-utils-firestore';
const adminUtilsFirestore = new FirestoreAdminUtils();

Documentation:

Collections

Target a firestore collection reference via:

const colRef = db.collection('test');
const utilColRef = adminUtilsFirestore.ref(colRef);
API
  • deleteFieldDocs For each documents in a referenced collection performs a delete operation of the old field key
utilColRef.deleteFieldDocs('fieldKeyToDelete')
  • importDocs Allow to import documents in a collection using a bulk operation
utilColRef.importDocs({uid: '1'}, {uid: '2', name: 'Giovanni'})
  • renameFieldDocs For each documents in a referenced collection performs a update operation of the new field key, and then performs, if it exist, a remove operation of the old field key
utilColRef.renameFieldDocs({oldFieldKey: 'newFieldKey'})
Documents

Target a firestore document reference via:

const docRef = db.collection('users').doc('xyz');
const utilDocRef = adminUtilsFirestore.ref(docRef);
API
  • renameField For the referenced document performs a update operation of the new field key, and then performs, if it exist, a remove operation of the old field key
utilDocRef.renameField({oldFieldKey: 'newFieldKey'})

Just a reminder

This in a unofficial library for Firestore (https://firebase.google.com/docs/firestore) we recommend replicating the operation, where it's possible, in a test project to check if the output is what expected before to run any operation in a production environment. Thanks for using and testing this library!

Contributing

For bugs and feature requests please Create an Issue.

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.2

4 years ago

0.1.3

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago