Firebase with React, v2 Manually Adding a Document to Firestore
React devs might find this archived course helpful to reference, but this course has been updated! We now recommend you take the Firebase Fundamentals course.
Transcript from the "Manually Adding a Document to Firestore" Lesson
>> Steve Kinney: We're not going to see a lot here, because we know that that is an empty array currently. Let's go ahead, and especially when we're playing out really early, we haven't wired up the ability to add posts yet. So what we'll do is we'll go ahead and we'll flip over to our database, and we'll cheat.
[00:00:15] We'll just hit Add a Collection. Cool thing about collections in Firebase is you don't necessarily need to add a collection. But if you went ahead and said okay, Firestore.doc/posts12345/comments678910/replies so on and so forth, it would make all the collections the whole way down for you. Right, so it's not like we have to sit there and think about your schema beforehand, the simple putting a document in that location will create all of the collections along the way for you.
[00:00:54] So we'll say that this is the post, and all right, we're gonna go with an auto ID, we give it a title, title should be,
>> Steve Kinney: Good Word About Cloud Firestore. The content will be, it's pretty great.
>> Steve Kinney: Real quick, I'll show you some of the options that you have, you can do numbers, booleans, maps are pretty much Java Script objects.
>> Steve Kinney: Cool, and so you can have maps, you can also go ahead and you can have arrays are kind of cheating. They're basically just maps where the value is true, and arrays are really hard with concurrency cuz yeah, I wanna get the third thing of that array, that could change, right?
[00:02:10] And so it’s really just keys and values under the hood, null, pretty straightforward, a time stamp we’ll see in a little bit. We saw that arrow we had before, reference [INAUDIBLE] and geopoint, which is kinda cool. So let's start with this, so we'll save this in the database.
[00:02:28] You see I have a post collection and now I have this very first document in here. And let's go back to my app, and we'll hit Refresh. And you can see that I have the data, and I have the ID, and it fetched it from the database, which is pretty great.