Firebase with React, v2 Firebase with React, v2

Manually Adding a Document to Firestore

Check out a free preview of the full Firebase with React, v2 course:
The "Manually Adding a Document to Firestore" Lesson is part of the full, Firebase with React, v2 course featured in this preview video. Here's what you'd learn in this lesson:

Steve demonstrates how to use the Firebase console to manually create a document inside of a collection.

Get Unlimited Access Now

Transcript from the "Manually Adding a Document to Firestore" Lesson

[00:00:00]
>> 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.

[00:01:32] They're not JavaScript objects but they are Java Script objects, right? And so basically a key value is to us, so we'd use something like a map [INAUDIBLE] do more things in it. So you can say user, and the UID is 123. I'm gonna regret all of this in a little bit when I have real users, but it'll be fine.

[00:01:53]
>> 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.