Neoclassical Philosophic Musings

    iopa-db-firebase

    1.4.9 • Public • Published

    IOPA
    iopa-db-firebase

    NPM NPM NPM

    NPM

    About

    This repository contains helper middleware functions for reading and writing to firebase

    Using

    npm install iopa-db-firebase --save

    Server

    var DBMiddleware = require('iopa-db-firebase');
     
    // SET THE FOLLOWING IN ENVIRONMENT VARIABLES INSTEAD!
    process.env.FIREBASE_CLIENT_EMAIL = "xxxx@xxxx-xxx.iam.gserviceaccount.com";
    process.env.FIREBASE_PRIVATE_KEY = "-----BEGIN PR...";
    process.env.FIREBASE_DATABASE_URL = "https://xxxxx-xxxx.firebaseio.com";
    process.env.FIREBASE_ROOT = "/";
     
    // Use the DBMiddleWare adds a .db object to every context record for remainder of chain
    app.use(require(DBMiddleware));
    app.use(require(DBMiddleware.filestorage));  // optional
    function(context, next){
     
        context.db.put("/demo/item", {
            id: "1234",
            name: "demo"
        });
     
        context.db.get("/demo/item")
        .then(function(item){
                context.log(item.timestamp);
        });
     
        context.db.put("/demo/item", null);
     
        context.db.subscribe("/demo")
        .on("value", function(item){
             context.log(item.key);
        });
     
    }

    Browser

    var DBMiddleware = require('iopa-db-firebase');
     
    // SET THE FOLLOWING IN ENVIRONMENT VARIABLES INSTEAD!
      process.env.BROWSER = true
      process.env.FIREBASE_API_KEY" = "THISISMYPRIVATETOKEN"
      process.env.FIREBASE_AUTH_DOMAIN" = "xxxxxx.firebaseapp.com"
      process.env.FIREBASE_DATABASE_URL" ="https://xxxxx.firebaseio.com"
      process.env.FIREBASE_STORAGE_BUCKET" = "xxxxx.appspot.com"
      process.env.FIREBASE_MESSAGING_SENDER_ID = "nnnnnnnnnn"
      process.env.FIREBASE_ROOT": "/"
     
     
    // Use the DBMiddleWare adds a .db object to every context record for remainder of chain
    app.use(require(DBMiddleware));
    function(context, next){
     
        context.db.put("/demo/item", {
            id: "1234",
            name: "demo"
        });
     
        context.db.get("/demo/item")
        .then(function(item){
                context.log(item.timestamp);
        });
     
        context.db.put("/demo/item", null);
     
        context.db.subscribe("/demo", function(item){
             context.log(item.key);
        });
     
    }

    License

    Apache-2.0

    API Reference Specification

    IOPA

    Install

    npm i iopa-db-firebase

    Homepage

    iopa.io

    DownloadsWeekly Downloads

    0

    Version

    1.4.9

    License

    Apache-2.0

    Last publish

    Collaborators

    • nodekit-io