fireboost
v1.0.2
Published
Unofficial library Node.js Utils class for Firestore (https://firebase.google.com/docs/firestore)
Downloads
134
Readme
Helpers used for common admin tasks on Firebase (Authentication, Firestore).
Installation:
- To install fireboost using npm, open a terminal/console window and enter the following command:
npm install --save fireboost
- Init fireboost via:
import {FireBoost} from 'fireboost';
const fireBoost = new FireBoost();
Documentation:
Authentication
Initializate fireboost with a Firebase App
import * as admin from 'firebase-admin';
import {FireBoost} from 'fireboost';
const serviceAccount = require('./service-account.json');
const app = admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: "__YOUR__DATABASE_URL__"
});
const appAuthRef = new FireBoost().auth(app);
API
- deleteAllUsers Delete all userRecors found in your Firebase App
appAuthRef.deleteAllUsers()
// teardown
.then(() => app.delete())
.catch(console.log);
Firestore
Collections
Target a firestore collection reference via:
const colRef = db.collection('test');
const utilColRef = fireBoost.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 = fireBoost.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.