firebase: update
This commit is contained in:
parent
1a1001e5e2
commit
f322e04cf2
12
Readme.md
12
Readme.md
|
@ -41,13 +41,17 @@ layout: 2017/sheet # 'default' | '2017/sheet'
|
||||||
|
|
||||||
# Optional:
|
# Optional:
|
||||||
updated: 2017-08-30 # To show in the updated list
|
updated: 2017-08-30 # To show in the updated list
|
||||||
ads: false # Add this to disable ads
|
ads: false # Add this to disable ads
|
||||||
weight: -5 # lower number = higher in related posts list
|
weight: -5 # lower number = higher in related posts list
|
||||||
deprecated: true # Don't show in related posts
|
deprecated: true # Don't show in related posts
|
||||||
prism_languages: [vim] # Extra syntax highlighting
|
prism_languages: [vim] # Extra syntax highlighting
|
||||||
---
|
---
|
||||||
```
|
```
|
||||||
|
|
||||||
|
For supported prism languages:
|
||||||
|
|
||||||
|
- <https://github.com/PrismJS/prism/tree/gh-pages/components>
|
||||||
|
|
||||||
## Setting up redirects
|
## Setting up redirects
|
||||||
|
|
||||||
This example sets up a redirect from `es2015` to `es6`:
|
This example sets up a redirect from `es2015` to `es6`:
|
||||||
|
|
|
@ -36,6 +36,12 @@ defaults:
|
||||||
type: article
|
type: article
|
||||||
category: "Others"
|
category: "Others"
|
||||||
excerpt_separator: "<!--more-->"
|
excerpt_separator: "<!--more-->"
|
||||||
|
prism_languages:
|
||||||
|
- jsx
|
||||||
|
- bash
|
||||||
|
- scss
|
||||||
|
- elixir
|
||||||
|
- ruby
|
||||||
|
|
||||||
# Site info
|
# Site info
|
||||||
url: http://ricostacruz.com/cheatsheets
|
url: http://ricostacruz.com/cheatsheets
|
||||||
|
|
|
@ -8,11 +8,6 @@
|
||||||
<script src='https://code.jquery.com/jquery-3.1.0.js'></script>
|
<script src='https://code.jquery.com/jquery-3.1.0.js'></script>
|
||||||
<script src='https://unpkg.com/isotope-layout@3.0.4/dist/isotope.pkgd.min.js'></script>
|
<script src='https://unpkg.com/isotope-layout@3.0.4/dist/isotope.pkgd.min.js'></script>
|
||||||
<script src='https://unpkg.com/prismjs@1.6.0'></script>
|
<script src='https://unpkg.com/prismjs@1.6.0'></script>
|
||||||
<script src='https://unpkg.com/prismjs@1.6.0/components/prism-jsx.min.js'></script>
|
|
||||||
<script src='https://unpkg.com/prismjs@1.6.0/components/prism-bash.min.js'></script>
|
|
||||||
<script src='https://unpkg.com/prismjs@1.6.0/components/prism-scss.min.js'></script>
|
|
||||||
<script src='https://unpkg.com/prismjs@1.6.0/components/prism-elixir.min.js'></script>
|
|
||||||
<script src='https://unpkg.com/prismjs@1.6.0/components/prism-ruby.min.js'></script>
|
|
||||||
{% for lang in page.prism_languages %}
|
{% for lang in page.prism_languages %}
|
||||||
<script src='https://unpkg.com/prismjs@1.6.0/components/prism-{{lang}}.min.js'></script>
|
<script src='https://unpkg.com/prismjs@1.6.0/components/prism-{{lang}}.min.js'></script>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
97
firebase.md
97
firebase.md
|
@ -1,71 +1,88 @@
|
||||||
---
|
---
|
||||||
title: Firebase
|
title: Firebase
|
||||||
|
prism_languages: [coffeescript]
|
||||||
|
tags: [WIP]
|
||||||
|
layout: 2017/sheet
|
||||||
---
|
---
|
||||||
|
|
||||||
wip
|
### Authenticating
|
||||||
|
|
||||||
### Starting
|
```js
|
||||||
|
FB = new Firebase('https://xxx.firebase.io')
|
||||||
``` coffee
|
FB.auth(TOKEN, (err, result) => { ···})
|
||||||
Fb = new Firebase('https://xxx.firebase.io')
|
|
||||||
Fb.auth(TOKEN, (err, result) -> ...)
|
|
||||||
.authAnonymously(...)
|
|
||||||
.authWithPassword(...)
|
|
||||||
.authWithOAuthPopup(...)
|
|
||||||
.authWithOAuthToken(...)
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Updating values
|
```js
|
||||||
|
FB.authAnonymously(···)
|
||||||
|
FB.authWithPassword(···)
|
||||||
|
FB.authWithOAuthPopup(···)
|
||||||
|
FB.authWithOAuthToken(···)
|
||||||
|
```
|
||||||
|
|
||||||
``` coffee
|
### Using
|
||||||
Users = Fb.child('users')
|
|
||||||
|
|
||||||
# create
|
```js
|
||||||
user = Users.push(first: "Frank", last: "Sinatra")
|
Users = FB.child('users')
|
||||||
|
```
|
||||||
|
|
||||||
# retrieve
|
```js
|
||||||
user = Users.child('alan') # gets `users/alan`
|
// Create
|
||||||
|
user = Users.push(first: "Frank", last: "Sinatra")
|
||||||
|
```
|
||||||
|
|
||||||
# setting
|
```js
|
||||||
user
|
// Retrieve
|
||||||
.set(first: "Miles", last: "Davis")
|
user = Users.child('alan') // gets `users/alan`
|
||||||
.update(first: "Miles")
|
```
|
||||||
.setWithPriority({ ... }, priority)
|
|
||||||
|
|
||||||
|
```js
|
||||||
|
// Update
|
||||||
|
user.set(first: "Miles", last: "Davis")
|
||||||
|
user.update(first: "Miles")
|
||||||
|
user.setWithPriority({ ··· }, priority)
|
||||||
|
```
|
||||||
|
|
||||||
# destroy
|
```js
|
||||||
user.remove()
|
// Destroy
|
||||||
|
user.remove()
|
||||||
|
```
|
||||||
|
|
||||||
# getting
|
```js
|
||||||
user.name() # primary id
|
// Getting
|
||||||
|
user.name() // primary id
|
||||||
|
|
||||||
user.once 'value', (snap) ->
|
user.once('value', (snap) => {
|
||||||
snap.name() # primary id
|
snap.name() // primary id
|
||||||
snap.val() # value
|
snap.val() // value
|
||||||
, (err) ->
|
}, (err) => {
|
||||||
|
···
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
# traversal
|
```js
|
||||||
user.parent()
|
// traversal
|
||||||
|
user.parent()
|
||||||
```
|
```
|
||||||
|
|
||||||
### Querying
|
### Querying
|
||||||
|
|
||||||
```coffee
|
```coffeescript
|
||||||
Users = Fb.child('users')
|
Users = FB.child('users')
|
||||||
Users
|
Users
|
||||||
.startAt(1000)
|
.startAt(1000)
|
||||||
.limit(50)
|
.limit(50)
|
||||||
.equalTo(priority, [name])
|
.equalTo(priority, [name])
|
||||||
.on 'child_added', (snap) -> ...
|
.on 'child_added', (snap) -> ···
|
||||||
```
|
```
|
||||||
### Lists
|
### Lists
|
||||||
|
|
||||||
```coffee
|
```coffeescript
|
||||||
Posts = Fb.child('posts')
|
Posts = FB.child('posts')
|
||||||
post = Posts.push({ title: "How to do things", author: "alan" })
|
post = Posts.push({ title: "How to do things", author: "alan" })
|
||||||
```
|
```
|
||||||
|
|
||||||
### References
|
## References
|
||||||
|
{: .-one-column}
|
||||||
|
|
||||||
* https://www.firebase.com/docs/web/api/
|
* <https://www.firebase.com/docs/web/api/>
|
||||||
* https://www.firebase.com/docs/web/recipes.html
|
* <https://www.firebase.com/docs/web/recipes.html>
|
||||||
|
|
Loading…
Reference in New Issue