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 "Update a Document Solution" Lesson
>> Steve Kinney: All right, so our mission is to be able to repeatedly star things. Let's flip back over and take a look. So if I go into this individual post, I had this removed. We can call this one, let's just call it star. So we have a number of stars that we pass into the component from the application state.
[00:00:29] So what we'll do in this case, we'll try postRef.update and that will take an object of the fields that I want to update. So in this case, we can do stars:
>> Steve Kinney: stars + 1. All right, let's take that for a spin. We actually have to put it on the button before it's gonna do anything.
[00:00:56] So scroll down.
>> Steve Kinney: We'll say onClick,
>> Steve Kinney: Star. The nice part is because the database is gonna automatically push out the updates, I don't have to do anything else. I just save the change I want to happen. It will change Firestore. Fire store will tell the application component things have changed.
[00:01:19] That'll update the application state. And we should, famous last words, be good to go. Here's the thing, is that if you just, one if you share your key, other people can push stuff, and two, is if you don't actually,
>> Steve Kinney: Wrap, it's wrapped in a function, let's see.
[00:01:44] It's just I have friends that are using my API key. So if I click it once it goes up once, [LAUGH] but when you push up your code and let other people pull it down [LAUGH], you could have friends that are also modifying your database. Let's hope everyone's playing.
[00:03:02] But let's talk a little bit about authentication.