From the course: Firebase Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Add restaurant wrapper functions

Add restaurant wrapper functions - Google Cloud Tutorial

From the course: Firebase Essential Training

Start my 1-month free trial

Add restaurant wrapper functions

- [Instructor] Okay, so that's our getReview function. Let's do restaurants now. This is going to be fairly straightforward. We're going to go into our restaurants directory and create a new file called getRestaurants.js and we're going to say import firebase from firebase/app and we'll say export const getRestaurant equals async and then the ID of the restaurant that we want to query and our query is going to look like this. It's going to be pretty similar to what we did with our user info. We're going to say const restaurantDoc equals await firebase.firestore.collection restaurants. We're going to get the restaurant using the ID that was passed into this function and we're going to execute our query by saying .get and then we'll get the data of our restaurant by saying const restaurant equals restaurantDoc.data and then we'll say return dot, dot, dot restaurant and we'll insert the ID into the data that we return as well…

Contents