Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nodefire-realtime

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nodefire-realtime

This package will be used for deal with firebase. Currently it helps to insert user defined data into the firebase realtime database.

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
increased by300%
Maintainers
1
Weekly downloads
 
Created
Source

nodefire-realtime

This package will be used for deal with firebase. Currently it helps to insert user defined data into your firebase realtime database. This packag is based on firebase-admin package.

const fcm = require('nodefire-realtime');

//For Initialize Firebase realtime DB
let serviceAccountKey = require("./serviceAccountKey.json");
let dbUrl = "https://<your-project-id>.firebaseio.com";
fcm.init(dbUrl, serviceAccountKey);
  1. Here, serviceAccountKey.json file is collection of various private keys. You have to download from firebase project>settings>Service accounts. After that click on Generate new private key.
  • (optional)After download that file you can rename it to serviceAccountKey.json.
  1. dbUrl is the path of your realtime database.
  • Go to Firebase console.
  • Select your Database project.
  • go to database.
  • You can see the url of your database, copy it.
//For insert
let dbReference = 'data/user/';
let child='school';
let data = {
    name: "John",
    city: 'new york'
}
fcm.insert(data, dbReference, child);

-> dbReference is like structure of your collection. data/user/ will become

data-
    |
     user-
          your collection data will insert here.
  1. child Sometimes we need to store group of data in the perticuler collection, for that you can use this parameter. However this parameter is optional so if there is no need to use child then you can ignore it. As our above example this will store data like this.
data-
    |
    user-
         |
         school-
                Your collection data will insert here. 

here is actual value store in Firebase.

--data--
        |
        user--
              |
              school--
                      name: John
                      city: New York
  1. let data = {} is used to store data to the firebase DB. It is JSON format data.

Final Code:

const fcm = require('nodefire-realtime');

//For Initialize Firebase realtime DB
let serviceAccountKey = require("./serviceAccountKey.json");
let dbUrl = "https://<your-project-id>.firebaseio.com";
fcm.init(dbUrl, serviceAccountKey);

//For insert
let dbReference = 'data/user/';
let child='school';
let data = {
    name: "John",
    city: 'new york'
}
fcm.insert(data, dbReference, child);

This package is complated for insert, and also in development phase. So, if you face any problems, then let me know.

Keywords

FAQs

Package last updated on 21 Aug 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc