Skip to content

Latest commit

 

History

History
71 lines (53 loc) · 1.11 KB

firebase.md

File metadata and controls

71 lines (53 loc) · 1.11 KB
title
Firebase

wip

Starting

Fb = new Firebase('https://xxx.firebase.io')
Fb.auth(TOKEN, (err, result) -> ...)
  .authAnonymously(...)
  .authWithPassword(...)
  .authWithOAuthPopup(...)
  .authWithOAuthToken(...)

Updating values

Users = Fb.child('users')

# create
  user = Users.push(first: "Frank", last: "Sinatra")

# retrieve
  user = Users.child('alan')  # gets `users/alan`

# setting
  user
    .set(first: "Miles", last: "Davis")
    .update(first: "Miles")
    .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