Created
May 24, 2017 13:01
-
-
Save diogomachado/f8cc7cc52a18ff9149a3d8109be165e5 to your computer and use it in GitHub Desktop.
Livro - firebaseTool
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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