Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,300 --> 00:00:06,780
We can move on to inserting the form data into the database will continue working in the register form
2
00:00:06,780 --> 00:00:07,500
component.
3
00:00:09,980 --> 00:00:15,620
At the top of the script, Block will structure the firebase module for the database object.
4
00:00:18,070 --> 00:00:24,340
It's time to end data to the database, the first step for inserting data into the database is to select
5
00:00:24,340 --> 00:00:25,090
a collection.
6
00:00:26,840 --> 00:00:28,680
Let's discuss some terminology.
7
00:00:29,030 --> 00:00:31,790
There are three words you're going to hear me throw around arounds.
8
00:00:32,030 --> 00:00:35,570
You may find these terms used frequently in the documentation.
9
00:00:35,900 --> 00:00:38,890
It's important we take the time to understand what they mean.
10
00:00:39,500 --> 00:00:41,360
The first term is Buckett.
11
00:00:41,690 --> 00:00:45,530
We've already talked about buckets when we created the firebase application.
12
00:00:45,830 --> 00:00:47,900
I want to recap what it is quickly.
13
00:00:48,260 --> 00:00:51,950
A bucket is a physical location where your data is stored.
14
00:00:52,400 --> 00:00:59,060
Firebase allows you to create multiple buckets if you're on a premium plan, you may want to do this
15
00:00:59,060 --> 00:01:01,250
if you want to keep certain data separate.
16
00:01:01,400 --> 00:01:04,040
We don't need that kind of flexibility at the moment.
17
00:01:04,220 --> 00:01:07,040
We can keep everything contained in one bucket.
18
00:01:07,640 --> 00:01:09,530
The second term is collection.
19
00:01:09,830 --> 00:01:12,140
Collections are objects in Firestar.
20
00:01:12,410 --> 00:01:14,510
They give you a way to organize data.
21
00:01:14,780 --> 00:01:16,790
You can think of them as categories.
22
00:01:16,940 --> 00:01:20,990
You don't want your data to get mixed with one another so carelessly.
23
00:01:21,260 --> 00:01:24,410
It's better to organize data in two separate objects.
24
00:01:24,710 --> 00:01:27,110
We'll be able to filter and sort through them.
25
00:01:27,740 --> 00:01:32,480
For example, you can have a user's collection for storing user data.
26
00:01:32,750 --> 00:01:38,810
You can have another collection for blog posts, settings, song uploads, lyrics, et cetera.
27
00:01:39,110 --> 00:01:45,560
Firebase requires you to select a collection before performing any actions on the database you cannot
28
00:01:45,560 --> 00:01:52,400
and data to the database until you choose a collection to add it to the last term is documents.
29
00:01:52,700 --> 00:01:55,790
Documents are the individual records in a collection.
30
00:01:56,090 --> 00:01:58,670
It's the data you stored in the database.
31
00:01:58,940 --> 00:02:05,060
Multiple documents can be stored in a single collection, will be mostly working with documents and
32
00:02:05,060 --> 00:02:06,590
collections in this course.
33
00:02:08,860 --> 00:02:15,160
We're going to select a collection in the firebase file, we could do this in the register form component
34
00:02:15,160 --> 00:02:19,610
file, but we'll be working with the users collection in multiple components.
35
00:02:19,960 --> 00:02:26,170
It's better to export the user collection so that it's accessible in all components below the variable
36
00:02:26,170 --> 00:02:27,030
definitions.
37
00:02:27,130 --> 00:02:30,940
I'm going to create a variable called user's collection.
38
00:02:31,330 --> 00:02:35,950
Its value will be the object returned by the DB collection function.
39
00:02:38,520 --> 00:02:44,790
The DVD collection has one argument, which is the name of the collection to select, we currently don't
40
00:02:44,790 --> 00:02:47,860
have any collections in the database, but that's all right.
41
00:02:48,150 --> 00:02:51,910
The collection doesn't need to exist for Firebase to select it.
42
00:02:52,260 --> 00:02:55,020
We're going to call the collection users.
43
00:02:57,580 --> 00:03:02,600
This function will return an object with methods and properties for working with the user's collection.
44
00:03:02,920 --> 00:03:05,320
The next step is to export this collection.
45
00:03:07,820 --> 00:03:13,940
We'll have access to the users collection in any component, switched back to the register form component
46
00:03:14,240 --> 00:03:17,390
in the import statement for the authentication object.
47
00:03:17,540 --> 00:03:22,070
We're going to change the DB object to the user's collection object.
48
00:03:24,520 --> 00:03:30,790
We only need the users collection object, the purpose of importing the database object was to select
49
00:03:30,790 --> 00:03:32,030
the users collection.
50
00:03:32,320 --> 00:03:35,890
However, we're already doing that inside the firebase file.
51
00:03:36,190 --> 00:03:40,940
It's no longer necessary to have it imported back in the registry function.
52
00:03:40,990 --> 00:03:43,260
We're going to use the user's collection.
53
00:03:43,510 --> 00:03:45,160
We'll call the ad function.
54
00:03:47,710 --> 00:03:54,730
The ADD function will add a document to the collection, a document is the terminology used to describe
55
00:03:54,730 --> 00:03:56,800
an object inside a collection.
56
00:03:57,190 --> 00:04:01,350
The ADD function has one argument, which is the object to insert.
57
00:04:01,690 --> 00:04:04,640
We're going to pass an object with the user data.
58
00:04:04,990 --> 00:04:08,820
We're not going to pass the values object directly to the function.
59
00:04:09,130 --> 00:04:15,370
We don't want to insert the password, confirm password and to US properties to the database.
60
00:04:15,520 --> 00:04:16,740
We can commit these.
61
00:04:17,200 --> 00:04:20,920
The password is already being stored in the authentication section.
62
00:04:21,250 --> 00:04:26,530
The U.S. property was to ensure the user agreed to the terms of service on the front end.
63
00:04:26,830 --> 00:04:30,480
Otherwise they wouldn't be able to submit the form in the first place.
64
00:04:30,790 --> 00:04:33,810
We won't bother storing that type of data in the database.
65
00:04:34,030 --> 00:04:39,190
Let's send the name email age and country properties to the object.
66
00:04:45,840 --> 00:04:52,980
The ad function will return a promise we're going to use async, await syntax to make our code readable,
67
00:04:53,310 --> 00:04:56,130
add the await keyword before the function call.
68
00:04:58,760 --> 00:05:03,860
We'll want to handle the air next Rapti request with a try catch statement.
69
00:05:09,000 --> 00:05:14,670
In the catch statement, we're accepting the error parameter, we're going to use the same code we used
70
00:05:14,670 --> 00:05:20,610
for handling the authentication request, copy and paste the code over to the new catch block.
71
00:05:23,030 --> 00:05:29,510
We're finished by using the ADD function, we're able to insert additional information into the database
72
00:05:29,750 --> 00:05:33,450
it say that we can't typically store in the authentication service.
73
00:05:33,690 --> 00:05:39,680
However, we are storing the email, even though the authentication service already stores it, it's
74
00:05:39,680 --> 00:05:41,690
still handy to store it in the database.
75
00:05:42,020 --> 00:05:45,580
This will allow us to filter and sort through the data by email.
76
00:05:46,160 --> 00:05:47,300
Let's try testing.
77
00:05:47,300 --> 00:05:50,180
If this works, we'll switch over to the browser.
78
00:05:52,780 --> 00:05:55,320
Make sure your developer tools are opened.
79
00:05:55,690 --> 00:06:02,020
We want to check for errors in the console after verifying there aren't errors in the console, fill
80
00:06:02,020 --> 00:06:04,780
out the registration form with valid values.
81
00:06:12,420 --> 00:06:18,720
After submitting the form, we will receive a success message, the council will continue to log the
82
00:06:18,720 --> 00:06:21,360
user's credentials information without a problem.
83
00:06:23,930 --> 00:06:30,170
We'll want to verify if the data is inserted into the database by checking the firebase console in the
84
00:06:30,170 --> 00:06:36,470
firebase console, navigate to the database page, if you already had it opened, then you should see
85
00:06:36,470 --> 00:06:39,260
the data because the database refreshes itself.
86
00:06:39,500 --> 00:06:41,870
If not, try manually refreshing.
87
00:06:41,870 --> 00:06:45,920
The page in the database will find three new columns.
88
00:06:46,130 --> 00:06:47,080
On the left.
89
00:06:47,120 --> 00:06:51,110
We have a list of collections before submitting the request.
90
00:06:51,230 --> 00:06:52,640
There were no collections.
91
00:06:52,910 --> 00:06:58,370
By adding a document to the collection, Firebase will check if the collection exists.
92
00:06:58,610 --> 00:07:00,850
If it doesn't, it'll create it for you.
93
00:07:01,220 --> 00:07:03,620
We didn't have to take care of that ourselves.
94
00:07:04,100 --> 00:07:07,850
In the middle column we have a list of documents in the collection.
95
00:07:08,240 --> 00:07:15,470
Documents are objects in a collection in the right column will find the data stored in a specific document.
96
00:07:15,890 --> 00:07:18,840
You can click on any of the documents to view its data.
97
00:07:19,190 --> 00:07:23,000
This collection is where we'll find the form data we submitted.
98
00:07:23,360 --> 00:07:25,840
All our data is present and accounted for.
99
00:07:26,420 --> 00:07:29,900
If we were to look at the name of the document, it's a random string.
100
00:07:30,290 --> 00:07:34,050
The random string is a generated unique ID for our data.
101
00:07:34,400 --> 00:07:36,250
This is important to understand.
102
00:07:36,560 --> 00:07:39,870
Databases need a way to track each individual record.
103
00:07:40,280 --> 00:07:44,810
This will allow us to pull a specific record or user if we ever need to.
104
00:07:45,170 --> 00:07:51,290
We could have provided an ID ourselves, but Firebase will create one for you if you don't provide what?
105
00:07:51,710 --> 00:07:55,640
We're going to let Firebase take care of assigning IDs for us.
10671
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.