Select to install this one Firebase REST API PUT POST C in CRUB GET R PATCH U

Select to install this one firebase rest api put post

This preview shows page 20 - 34 out of 54 pages.

Select to install this one
Image of page 20
Firebase REST API PUT & POST (C in CRUB) GET (R) PATCH (U) DELETE (D) 21 All request commands are case sensitive (all uppercases)
Image of page 21
GET curl '- 1b578.firebaseio.com/weather.json' Or curl -X GET '- 1b578.firebaseio.com/weather.json' 22
Image of page 22
Another example curl -X GET '- 1b578.firebaseio.com/examples/phoneNumb ers/0.json' {"number":"212 555-1234","type":"home"} 23 Note: refer to array element by index
Image of page 23
PUT curl -X PUT '- 1b578.firebaseio.com/weather.json' -d '"hot"' "hot" PUT: write a given value (e.g., "hot") to the specify node (e.g., "weather") Overwrite if node already has value 24
Image of page 24
PUT curl -X PUT '- 1b578.firebaseio.com/users/100.json' -d '{"name": "john"}' This will add a new node "users" (assuming it does not exist yet) and a child of this node with key "100" and content: {"name": "john"} 25
Image of page 25
Example Is the previous command the same as this? curl -X PUT -d '{"100": {"name": "John"}}' ' ' Can you think of a situation where two commands give different results? 26 Note we now write to the "users" node
Image of page 26
POST curl -X POST -d '{"name": "John"}' ' - 1b578.firebaseio.com/users.json ' Note post automatically generates a new key & then store the value for the new key In contrast, PUT will simply overwrite the value 27
Image of page 27
PATCH curl -X PATCH -d '{"name": "John Smith", "age": 25}' ' - 1b578.firebaseio.com/users/100.json ' PATCH performs the update if value already exists (e.g., name) ; otherwise, it inserts the new value (e.g., age) … an upsert 28
Image of page 28
DELETE curl -X DELETE '- 1b578.firebaseio.com/users/100.json' What does this do? curl -X DELETE ' - 1b578.firebaseio.com/users.json ' 29
Image of page 29
Query: filtering by key curl '- 1b578.firebaseio.com/users.json? orderBy="$k ey "& equalTo ="200"' This returns: {"200":{"age":25,"name":"David"}} 30 Must be a string. Why?
Image of page 30
Another example curl '- 1b578.firebaseio.com/users.json?orderBy="$k ey"& startAt ="200"' This returns: {"200":{"age":25,"name":"David"},"300":{"gender ":"female","gpa":4.0,"name":"Mary"}} 31 Users with keys >= 200
Image of page 31
Ways of filtering data By key: orderBy="$key" By child key: orderBy="<path-to-child-key>" By value: orderBy="$value" 32 Key (direct) child key: address (nested) child key: address.city
Image of page 32
Parameters startAt endAt equalTo limitToFirst limitToLast 33
Image of page 33
Image of page 34

You've reached the end of your free preview.

Want to read all 54 pages?

  • Fall '14
  • JSON, Representational State Transfer, ECMAScript

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes