Coder Social home page Coder Social logo

siarheidudko / firebase-admin-cli Goto Github PK

View Code? Open in Web Editor NEW
6.0 3.0 0.0 879 KB

Cli for firebase

Home Page: https://www.npmjs.com/package/firebase-admin-cli

License: GNU General Public License v3.0

JavaScript 100.00%
authentication cli data-manipulation data-migratation data-science firebase firebase-admin firebase-auth firebase-authentication firebase-database

firebase-admin-cli's Introduction

firebase-admin-cli

Empower Your Firebase Project with Ultimate Control: Unleash the Full Potential of Firebase's Auth, Realtime Database, Firestore, Storage, and More, All Through a Powerful Command Line Interface with Admin Privileges!

npm npm NpmLicense GitHub last commit GitHub release

Install

npm i firebase-admin-cli -g

Run

> export GOOGLE_APPLICATION_CREDENTIALS=/FULL_PATH_TO_YOUR_SERVICE_ACCOUNT.json
> firebase-cli

How to use

Just use JavaScript to manage the database.

  • You can use one-line commands
console.log(
  await db
    .collection("users")
    .get()
    .then(({ docs }) => docs.map((e) => e.data()))
);
const users = await db.collection("users").get();
console.log(users.docs.map((e) => e.data()));
  • You can insert multi-line scripts
// command 1 (use Ctrl + V to input multiline code)
const users = await db.collection("users").get();
const arr = users.docs.map((e) => e.data());
console.log(arr);
  • You can assign the result of a command to variables and use them in another command
// command 1
const users = await db.collection("users").get();
// command 2
const arr = users.docs.map((e) => e.data());
// command 3
console.log(arr);
  • You can output the result of the command to the console (you can study the structures and utility properties and methods of objects)
console.log(await db.collection("users").get());
  • You can even execute your script from a file using require();
require("../my_migration_script.js").run();

my_migration_script.js

const admin = require("firebase-admin");

module.exports.run = async () => {
  const users = await admin.firestore().collection("users").get();
  const arr = users.docs.map((e) => e.data());
  console.log(arr);
};

Example

siarhei@MacBook-Pro firebase-admin-cli % export GOOGLE_APPLICATION_CREDENTIALS=/Users/siarhei/Projects/firebase-admin-cli/serviceAccount.json
siarhei@MacBook-Pro firebase-admin-cli % firebase cli

> [email protected] start
> node ./bin/firebase-cli.js

The following settings are loaded:
Service Account from file: /Users/siarhei/Projects/firebase-admin-cli/serviceAccount.json
Project id: fir-engine-f1dcd
┌─────────┬──────────┬───────────────────────────────────────────┬─────────────────────────────┐
│ (index) │ command  │                   title                   │            alias            │
├─────────┼──────────┼───────────────────────────────────────────┼─────────────────────────────┤
│    0    │ 'help()''Сall current help''help()'           │
│    1    │  'auth''Сall firebase authorization interface''admin.auth()'        │
│    2    │  'rtdb''Сall firebase database interface''admin.database()'      │
│    3    │   'db''Сall firebase firestore interface''admin.firestore()'     │
│    4    │ 'bucket''Сall firebase storage/bucket interface''admin.storage().bucket()'  │
│    5    │ 'types''Сall firebase firestore types interface''admin.firestore'      │
│    6    │ 'exit()''Exit console''terminalInterface.close()' │
└─────────┴──────────┴───────────────────────────────────────────┴─────────────────────────────┘
Firebase Admin CLI (fir-engine-f1dcd)>const users = await db
  .collection('users')
  .get();
console.log('users', users.docs);
Firebase Admin CLI (fir-engine-f1dcd)>
users []
Firebase Admin CLI (fir-engine-f1dcd)>

firebase-admin-cli's People

Contributors

siarheidudko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.