Thursday 3 March 2016

Firebase

firebase guide

Android quickstart

Firebase - unity

some extra examples of possibilities (on the right)

Getting stated with Firebase

(covers: hosting, real time DB, user authentication)



Realtime database via html add <script> to link to firebase
to access Firebase,create a reference to the root of firebase url:
var myDataRef = new Firebase('https://k0xssycfcm6.firebaseio-demo.com/');

every piece of data has its onURL, this url can be used to access data from:

  • any Firebase client library
  • the firebase REST API
  • or by entering it in any browser.

to set.........   myDataRef.set('User ' + name + ' says ' + text);
to write an object with text and name properties: ... myDataRef.set({name:name, text:text});
When objects are written to the database, the structure of the object is mapped to database locations. In this example, when the object {name: name, text: text} is set, locations for name and text are automatically created as children of the location referenced by myDataRef.
to write lists: myDataRef.push({name: name, text: text});
Reading Data:... myDataRef.on('child_added', function(snapshot) { //}
child_added' event notifies of new additions.);
you always read data using callbacks
Using Snapshots: .... var message = snapshot.val();
                               displayChatMessage(message.name, message.text);

Re-Architecting a Firebase app to work with Node.js and MongoDB
  1. Firebase is a real-time engine with backward connectivity. I.e. you might build an app where clients subscribe to events on specific data and server actively informs clients about changes
  1. Data layer is hosted for you. It's a nice kickstarter solution. Including auth management
  1. Geo-Fire. Realtime geo coordinates solution.
here is a nice article how to replace Firebase in your app with Node.js+MongoDb. It shows how much work you would have to do on your own, and explains, IMHO, why a startup (small app) should begin with Firebase (if real-time updates to clients are required) and proceed with MongoDb (in any case self-written solution) if the projects keeps evolving


Using Firebase with MEAN:

Firebase replaces the MongoDB (M) and can replace Express (E) with its free hosting and ability to act as an alternative to the typical RESTful strategy, turning server stacks into "scriptlets"


We could potentionally still use Node / Express for a server framework with Angular as client framework, using Firebase just as a data source as opposed to MongoDB.
As initial configuration would be different, you would need to remove references to MongoDB /Mongoose, if you were to start with a generator ( like Yeoman / MEAN boilerplate ).
This can be seen as a FAN stack (firebase/angular/node.js)



No comments:

Post a Comment