Firebase

Authenticating

FB = new Firebase('https://xxx.firebase.io')
FB.auth(TOKEN, (err, result) => { ยทยทยท})
FB.authAnonymously(ยทยทยท)
FB.authWithPassword(ยทยทยท)
FB.authWithOAuthPopup(ยทยทยท)
FB.authWithOAuthToken(ยทยทยท)

Using

Users = FB.child('users')
// Create
user = Users.push(first: "Frank", last: "Sinatra")
// Retrieve
user = Users.child('alan')  // gets `users/alan`
// Update
user.set(first: "Miles", last: "Davis")
user.update(first: "Miles")
user.setWithPriority({ ยทยทยท }, priority)
// Destroy
user.remove()
// Getting
user.name()  // primary id

user.once('value', (snap) => {
  snap.name()  // primary id
  snap.val()   // value
}, (err) => {
  ยทยทยท
})
// traversal
user.parent()

Querying

Users = FB.child('users')
Users
  .startAt(1000)
  .limit(50)
  .equalTo(priority, [name])
  .on 'child_added', (snap) -> ยทยทยท

Lists

Posts = FB.child('posts')
post = Posts.push({ title: "How to do things", author: "alan" })

References

{: .-one-column}

Last updated