Skip to content

Commit efa637b

Browse files
authored
improve push documentation
1 parent f9a0439 commit efa637b

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

README.md

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ https://www.firebase.com/signup/
1212

1313

1414

15-
##get, put and push
15+
##get and put
1616

17-
`get` gets the value of a Firebase at some URL, `put` writes or replaces data at the path defined by URL and `push` appends data to a list at the path defined by URL. A new ID is also generated every time you `push` to a Firebase URL.
17+
`get` gets the value of a Firebase at some URL, `put` writes or replaces data at a Firebase path.
1818

1919
```python
2020
>>> import firebase
@@ -36,15 +36,27 @@ tell me everything
3636

3737
>>> print firebase.get(URL + '/color')
3838
red
39+
```
40+
41+
42+
43+
##push
44+
45+
`push` pushes data to a list on a Firebase path. This is the same as `patch`ing with an incrementing key, with Firebase taking care of concurrency issues.
46+
47+
```
48+
>>> import firebase
49+
>>> URL = 'bickering-blancmanges'
50+
>>> print firebase.get(URL)
51+
None
3952
40-
>>> #Whereas using put replaces existing data, push simply appends to a list
41-
>>> firebase.push(URL+'/listexample',{'color':'red'})
42-
>>> firebase.get(URL+'/listexample')
43-
{'u'-JyAXHX9ZNBh7tPPja4w':{'color':'red'}}
53+
>>> firebase.push(URL, {'color': 'pink', 'jiggliness': 'high'})
54+
>>> firebase.get(URL)
55+
{'u'-JyAXHX9ZNBh7tPPja4w': {'color': 'pink', 'jiggliness': 'high'}}
4456
45-
>>> firebase.push(URL+'/listexample',{'color':'green'})
46-
>>> firebase.get(URL+'/listexample')
47-
{'u'-JyAXHX9ZNBh7tPPja4w':{'color':'red'},'-JyAXHX9ZNBh7tPPjasd':{'color':'green'}}
57+
>>> firebase.push(URL, {'color': 'white', 'jiggliness': 'extreme'})
58+
>>> firebase.get(URL)
59+
{'u'-JyAXHX9ZNBh7tPPja4w': {'color': 'pink', 'jiggliness': 'high'}, '-JyAXHX9ZNBh7tPPjasd': {'color': 'white', 'jiggliness': 'extreme'}}
4860
```
4961

5062

0 commit comments

Comments
 (0)