Firebase recently got a huge upgrade from Google, with a slew of new services and tighter integration into the overall Google ecosystem. I’ve been a big fan of Firebase for years, specifically since they have a really nice integration with EmberJS via Emberfire. This lets you streamline frontend development in a huge way since Firebase’s storage syncs automatically to the client data model with essentially no boilerplate code — it’s all there in the client libraries for you. Boom.
I recently blogged about an application from the IoT World Hackathon that implements an EmberJS frontend just like this, fed by data updating from scriptr.io on the backend. All of the code for both the scriptr.io endpoints and the Ember frontend are there for you to use as a model, but to make an integration like this even easier, we’re releasing a connector library for Firebase as well.
Using this connector is a cinch.
- Clone this repo and sync it to your account (this process will be much easier very soon, once we’ve released our auto-import functionality). You’ll now see ALL of our connectors in your scriptr.io IDE.
- Find the Firebase folder, then config.js, and fill in your Firebase project name.
- Run test.js! It will connect to your database, push some data, and then do a separate call to get it back. If everything is working, you’ll see the successful responses in the console.
To use this connector in a new script, require the firebaseclient, then create an instance of the Firebase class.
var firebaseModule = require('modules/firebase/firebaseclient.js'); var firebase = new firebaseModule.Firebase();
To create some data:
var data = { "alanisawesome": { "name": "Alan Turing", "birthday": "June 23, 1912" } } firebase.putData("users", data);
You might want to get that data back. Do this:
firebase.getData("users");