Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase javascript promise in NodeJS

I need to deploy a node.js server for some complicated business logic.

Is there any firebase library/module which allows me to use promises and not callbacks for the query and update/set methods?

I've found firebase-client, but it is based on REST. Am much prefer one based on the javascript API, if there is one out there?

Thanks.

like image 642
jho Avatar asked Jan 31 '15 01:01

jho


2 Answers

You're looking for Fireproof.

Fireproof wraps Firebase objects with lightweight promise support.

var Fireproof = require('fireproof'),
  Firebase = require('firebase');

var fb = new Firebase('https://test.firebaseio.com/thing'),
  fp = new Fireproof(fb);

fireproof.auth('my_auth_token').then(function() {
  fp.child('path/to/data').then(...);
}, function(err) {
  console.error('Error authenticating to Firebase!');
})
like image 188
josh3736 Avatar answered Nov 14 '22 11:11

josh3736


now they have integrated promises in firebase it self. https://www.firebase.com/blog/2016-01-21-keeping-our-promises.html

like image 3
chamara Avatar answered Nov 14 '22 12:11

chamara