Skip to content

Instantly share code, notes, and snippets.

@diogomachado
Created May 24, 2017 13:01
Show Gist options
  • Save diogomachado/f8cc7cc52a18ff9149a3d8109be165e5 to your computer and use it in GitHub Desktop.
Save diogomachado/f8cc7cc52a18ff9149a3d8109be165e5 to your computer and use it in GitHub Desktop.
Livro - firebaseTool
(function() {
angular.module('app').factory('firebaseTool', firebaseTool);
function firebaseTool(){
var service = {};
service.create = function(url, objeto){
var nova_chave = firebase.database().ref().child(url).push().key;
var data = {};
data[url + nova_chave] = objeto;
firebase.database().ref().update(data);
return nova_chave;
}
service.set = function(url, objeto){
firebase.database().ref(url).set(objeto);
}
return service;
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment