From the course: Building Production-Ready React Apps: Setup to Deployment with Firebase
Unlock the full course today
Join today to access over 24,500 courses taught by industry experts.
Set a new document and store and sync data into the Cloud Firestore
From the course: Building Production-Ready React Apps: Setup to Deployment with Firebase
Set a new document and store and sync data into the Cloud Firestore
- [Instructor] To create a new document, we're going to follow the documentation here. So basically what you need to do is to create a reference with the instance of the database, specify the name of the collection, then an index, and then you're going to use this built-in function method provided by the SDK to specify your new documents. So let's copy those two lines and we're going to do the same in our firestore module. We just need to adapt to our needs because here the goal is to set a new documents for any new upload of images. So I'm going to name this one docRef, and here I'm going to specify stocks for the name of the collection. And here I'm going to use a random index, randomIndex, I'm going to do that with JavaScript Math.floor, and that's going to be Math.random. And I'm going to allow to generate from a very large number like so. And here I'm going to replace with, I'm going to use the back tick because…
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
-
-
-
-
-
-
-
-
Get started with the Cloud Firestore3m
-
(Locked)
Learn to add and manage data5m
-
(Locked)
Set a new document and store and sync data into the Cloud Firestore5m 53s
-
(Locked)
Learn to read data from a collection5m 32s
-
(Locked)
Get documents and display them in the app5m 18s
-
(Locked)
Define React environment variables4m 39s
-
-
-
-
-
-
-