I am going to create my own JavaScript client library, and I like the way Firebase format queries are. I am trying to understand what is happening. From viewing the web manual here, I found the code below:
var ref = new Firebase("https://docs-examples.firebaseio.com/web/saving-data/fireblog"); var usersRef = ref.child("users"); usersRef.set({ alanisawesome: { date_of_birth: "June 23, 1912", full_name: "Alan Turing" }, gracehop: { date_of_birth: "December 9, 1906", full_name: "Grace Hopper" } });
I see that ref is equal to a function called Firebase , and usersRef is equal to ref.child .
I present something like this:
Firebase = function(url) { this.child = function(path) { console.log(url); console.log(path); }; };
Here I see that usersRef.set is usersRef.set called, but I canโt figure out how and where it will go? Is set function or object? I noticed that firebase has set() , update() , push() and transaction() , making me think these are functions.
"TypeError: Cannot read property 'set' of undefined
Maybe I'm on the wrong track, I'm just not familiar with this pattern.
source share