WEBVTT

00:00.780 --> 00:03.270
So we saw the very basics of using faker.

00:03.450 --> 00:05.040
Really just a single line.

00:05.130 --> 00:07.350
You know it's the thing and that it's a package.

00:07.560 --> 00:12.830
Now our game plan from here on out is to use faker to generate our data for us.

00:12.840 --> 00:14.650
Get 500 users in there.

00:14.850 --> 00:20.240
But faker on its own won't do that so will use this favorite Internet e-mail.

00:20.660 --> 00:21.930
We want one of those.

00:22.170 --> 00:28.020
We want 500 of those actually and we'll use the date passed and the reason we need to use data past

00:28.350 --> 00:31.030
is that when a user is created.

00:31.140 --> 00:31.700
Yes.

00:31.860 --> 00:37.160
You know in the real world we want to store the current time when they actually signed up.

00:37.500 --> 00:43.080
But when we're inserting 500 fake users we don't want them all to have the exact same time that they're

00:43.080 --> 00:46.360
joining because then that throws off our data.

00:46.410 --> 00:49.850
Right for having 500 users who joined at the same exact instant.

00:50.070 --> 00:53.520
So we'd much rather spread them out so that we could try certain things with the data.

00:53.520 --> 00:54.560
Play around with it.

00:54.600 --> 00:56.850
So we're going to generate data using this.

00:56.850 --> 01:02.370
So then the next logical question is OK we know how to generate a single email and a single date.

01:02.370 --> 01:04.230
How do we do 500 of them.

01:04.230 --> 01:08.720
And more importantly how the heck do we get them in a minuscule database.

01:09.150 --> 01:11.580
So warning appear red letters.

01:11.580 --> 01:14.260
This is not really code that will work well.

01:14.310 --> 01:16.980
It's not code that will work that will work at all.

01:16.980 --> 01:18.410
But I just want to show you.

01:18.630 --> 01:21.270
We would want to do something like this right.

01:21.270 --> 01:24.380
Insert into user's e-mail and create it at.

01:24.720 --> 01:30.270
And the values you want a faker an Internet e-mail and fake or date date of past.

01:30.300 --> 01:34.350
This is sort of a hybrid between my as well and node.

01:34.350 --> 01:35.930
Unfortunately this doesn't work.

01:36.060 --> 01:38.040
But this is what we're going for right.

01:38.040 --> 01:39.800
We want to do something like this.

01:39.990 --> 01:43.950
Insert 500 of these where we get a fake e-mail a fake date.

01:43.950 --> 01:46.230
The problem is inserted into users.

01:46.230 --> 01:51.400
This syntax only exists in my as well and faker only exists in node.

01:51.510 --> 01:53.410
So how do we bridge that connection.

01:54.630 --> 01:56.650
Oh and we want to use that 500 times.

01:56.820 --> 01:57.600
Right.

01:57.600 --> 02:00.500
The answer is that we use something called My.

02:00.510 --> 02:07.110
Q Well and it's confusing because it's a node package like fakers and other package called my s.

02:07.110 --> 02:11.060
Q Well what it does is it connects to my as.

02:11.060 --> 02:14.330
Q Well the actual database and it talks to it.

02:14.580 --> 02:17.750
So every language there are a couple of different packages.

02:17.750 --> 02:19.960
You know PDP has a way of talking to mice.

02:20.090 --> 02:22.890
Mice Well Ruby has a couple of ways.

02:23.010 --> 02:24.820
They are kind of adapters.

02:24.840 --> 02:31.230
Think of it as a connector between the two a tube or a pipeline and there's a couple for node but the

02:31.230 --> 02:36.660
one we're using is the most popular It's called My as well which personally I find kind of confusing.

02:36.660 --> 02:39.780
I wish it was called you know minuscule node or Maia's.

02:39.780 --> 02:43.460
Q Well connecter or my s to LJ s or something.

02:43.530 --> 02:46.460
And here's a couple of diagrams of basically how it works.

02:46.470 --> 02:48.330
So we have node on unten.

02:48.330 --> 02:49.960
This is where we've been working.

02:50.100 --> 02:53.820
And then we have MY as well on its own our separate database.

02:53.890 --> 03:01.510
So this has are data stored in it and the Maia's queue package will be able to say things like hey my

03:01.560 --> 03:08.330
ask your database how many users are in there ask it to the database and then the my ask well database

03:08.370 --> 03:13.770
will be able to say Well looks like there are currently 518 users send that back to node and we can

03:13.770 --> 03:18.380
use it or might be something like this.

03:18.450 --> 03:19.200
Hey there it is.

03:19.210 --> 03:20.030
Q our database.

03:20.070 --> 03:21.560
How many users are in there.

03:21.840 --> 03:24.790
And my ask we all might say users.

03:24.990 --> 03:26.420
I have no idea what you're talking about.

03:26.420 --> 03:32.420
I don't have a users table in here in which case we would get that back to No.

03:32.440 --> 03:38.850
Yes and we'd be able to know that because of the package we're using my s q our package is both asking

03:38.850 --> 03:39.650
the questions.

03:39.650 --> 03:43.720
All right it's querying the database and it's handling the replies.

03:43.940 --> 03:49.470
So then in here we can write logic that says OK if we don't get a response if there's an error message

03:49.740 --> 03:50.980
let's do one thing.

03:51.150 --> 03:55.570
Otherwise do something else or a third scenario.

03:56.040 --> 04:03.110
Hey there may as well our adaptor or my ass Our connector might ask how many users are in your database.

04:03.390 --> 04:05.690
And there is no database.

04:06.000 --> 04:07.280
We don't get a spot.

04:07.530 --> 04:09.920
Well we need to figure out how to handle that node.

04:09.930 --> 04:16.110
Unfortunately fortunately the my as well package handles that so it will you know start by freaking

04:16.110 --> 04:16.260
out.

04:16.260 --> 04:17.020
Are you there.

04:17.040 --> 04:18.000
What's going on.

04:18.020 --> 04:21.230
Bunch of sad faces but then they will figure it out.

04:21.250 --> 04:26.180
It will basically time out and it will figure out there's no connection there's no database there.

04:26.490 --> 04:29.800
And we'll be able to handle that as well which is something that could happen.

04:30.030 --> 04:31.970
Your database server could go down.

04:32.250 --> 04:33.510
Something could go wrong.

04:33.780 --> 04:36.160
So these are different scenarios.

04:36.240 --> 04:41.070
Mainly we're working with this one right where there's good communication and everything's working how

04:41.070 --> 04:42.090
it should.

04:42.390 --> 04:49.520
But the key thing is that the package my rescue package works in node talks to a database.

04:49.740 --> 04:53.110
So without further ado let's see how that works.
