48 Update data function phone

48 update data function phone

This preview shows page 8 - 9 out of 9 pages.

Image of page 8
Update data function updateUserData(userId, phone) { firebase.database().ref("users/"+userId). update ({ phone: phone }); } updateUserData("123", "(626)123-0000"); 49 Note this does not remove other data of user 123 What if you replace "update" with "set"? Retrieve a list of values userRef = firebase.database().ref("users"); userRef.on("value", function(snapshot) { snapshot.forEach(function(child) { console.log (child.key + ": " + child.val()); }); }); 50 Press Ctrl+Shift+J in Chrome for console window Listening to child events instead userRef.on("value", function(snapshot) {… Will retrieve a list of values in the path specified by userRef Not efficient, since entire list will be retrieved whenever changes occur userRef.on("child_added", function(…)) {… Firebase will callback for every existing child and new child added to the path userRef Other events: child_changed, child_removed 51 Filtering data queryRef = firebase.database().ref("users"). orderByChild ( "name"). equalTo ("David"); queryRef.on("value", function(snapshot) { snapshot.forEach(function(child) { console.log(child.key + ": " + child.val()); }); }); 52 Resources Add Firebase to your JavaScript Project Getting Started with Firebase on the Web ature=youtu.be Realtime Database: Installation & Setup in JavaScript, Read & Write Data … 53 Resources Firebase REST API database/ Requests for Python - requests.org/en/master/user/quickstart/#make-a- request 54
Image of page 9

You've reached the end of your free preview.

Want to read all 9 pages?

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

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

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