I'm trying to create a simple node.JS command-line script to interact with Firebase using their Javascript API. I want the tool to close the Firebase connection and terminate once it has finished it's interaction.
Here is some sample code showing what I am trying to achieve:
var Firebase = require('firebase');
var myRootRef = new Firebase('https://myprojectname.firebaseIO-demo.com/');
myRootRef.set('It's working!');
One possible solution would be adding a callback and calling process.exit():
var Firebase = require('firebase');
var myRootRef = new Firebase('https://myprojectname.firebaseIO-demo.com/');
myRootRef.set("It's working!", function() {
process.exit(0);
});
However, I would love to have a more elegant solution than forcing the process to terminate with process.exit().
Any ideas?
This can probably be solved with
firebase.database().goOffline()
. Got this from another thread: https://stackoverflow.com/a/37858899i'm not keen on forcing disconnect with
process.exit(0)
either.. as i only require data persistence (not real-time features) i use the REST API.. I find plain HTTPS twice as fast as the official firebase npm module..