Trying to use Firebase as a nodejs module. And i have a problem:
Firebase docs say to code for nodejs the same as for javascript Firebase library.
var newChildRef = myRootRef.push{{name: "Child1"}, function(error){
if(!error){
myModel.addChildto(newChildRef); // Here is calling global var inside a callback!
}
});In nodejs we need to use async calls to databases. So the standard node way is:
myRootRef.push{{name: "Child1"}, function(newChildRef,error){
if(!error){
myModel.addChildto(newChildRef);
}
});Please explain how should I code in node js using Firebase, not to spoil an async style.
var Firebase = require('firebase');
var myRootRef = new Firebase('https://test.firebaseio-demo.com');var start = new Date().getTime();for(var i = 0; i < 1000; i++) {var newChildRef = myRootRef.push();}console.log('Elapsed', new Date().getTime() - start);
For more options, visit https://groups.google.com/d/optout.