From the course: Firebase Essential Training
What is Firestore? - Google Cloud Tutorial
From the course: Firebase Essential Training
What is Firestore?
- The next Firebase tool we're going to look at in this section is something called Firestore. And this will allow us to add some database functionality to our app. Firestore is Firebases NoSQL database service that we'll be using to store data for things like users, restaurants, reservations, and so on. Firestore greatly simplifies the whole process of working with database data. While normally we'd have to create multiple server endpoints and then have our app make requests to the server, to read data from, or make changes to the database, with Firestore we can make these changes directly from inside our client-side code. And while we obviously don't want to do this in all cases for security reasons, this can greatly simplify some very common tasks. We'll learn more about all of this shortly. So let's learn a few of the details behind Firestore. As I mentioned, Firestore is a NoSQL database, which means that data isn't stored in rigid columns as in regular SQL databases, many JavaScript developers prefer to work with NoSQL databases, since the data they contain as most often stored as JSON objects, which fits in very nicely when the rest of your application is written in JavaScript. In Firestore, the data is stored as almost JSON. That is the data is allowed to have extra types. And each document is limited to one megabyte in size. The terminology for how this JSON data is stored is this. We have simple data stored as documents and series of related documents are stored in collections. So for example, in a little bit, we'll be creating collections of users, restaurants, reservations, and reviews. And each of these collections will consist of a number of documents, which will contain data about an individual user and individual restaurant, and so on. Now something that's important to note is that Firebase is optimized to store many smaller documents. So just as an example, instead of storing our user data like this, where the user's data includes their reservation, data reviews, they've left, et cetera directly. We'll want to split those up each into their own document. And instead link the two using unique IDs. We'll see exactly how this is done shortly. Another thing about Firestore and a very nice feature that, is that Firestore is built to allow us to subscribe, to changes in the data so that when the data changes in our Firestore, our app will immediately have access to the updates. In our particular case, this means that we won't have any trouble making sure that users can only make reservations that are actually available since if a reservation is suddenly taken by another user, our app almost immediately receive an updated version of that data and display that that reservation has been taken. Another detail that I'm going to mention right now. And we'll see more about this later on as well, is that access to Firestore documents is controlled by something called security rules. Basically, these are things that we can define to make sure users are only allowed to access things they're supposed to access. For example, in our application, we wouldn't users to be able to cancel each other's reservations and we'll see how to write security rules shortly. Now, there's one last thing that I think is important to mention before we move on while we're going to be using Firestore in this course, Firebase actually provides another database option, something called Realtime database. And there are a lot of fairly subtle differences between Firestore and Realtime database. But the main one is this, Firestore is just better for most used cases. I realized that that's a pretty big statement to make without much backup, but I really believe it's true. I'm not going to go into too much detail here, but after we've learned about Firestore, I'd recommend that you go ahead and give Realtime database a try and you'll see what I mean. Realtime database is just more cumbersome to work with and doesn't provide nearly as much functionality as Firestore does.
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
What is Firestore?3m 47s
-
(Locked)
Firestore query basics7m 18s
-
(Locked)
Set up a Firestore database3m 52s
-
(Locked)
Firestore security rules8m 18s
-
(Locked)
Populate Firestore with development data8m 57s
-
(Locked)
Add user wrapper functions5m 59s
-
(Locked)
Add review wrapper functions4m 30s
-
(Locked)
Add restaurant wrapper functions1m 20s
-
(Locked)
Add reservation wrapper functions6m 46s
-
(Locked)
Add Firestore to a project7m 5s
-
(Locked)
Implement edit profile functionality6m 30s
-
(Locked)
Load available times8m 41s
-
(Locked)
Firestore pricing4m 49s
-
-
-
-
-
-
-