So we saw the very basics of using faker.
Really just a single line.
You know it's the thing and that it's a package.
Now our game plan from here on out is to use faker to generate our data for us.
Get 500 users in there.
But faker on its own won't do that so will use this favorite Internet e-mail.
We want one of those.
We want 500 of those actually and we'll use the date passed and the reason we need to use data past
is that when a user is created.
Yes.
You know in the real world we want to store the current time when they actually signed up.
But when we're inserting 500 fake users we don't want them all to have the exact same time that they're
joining because then that throws off our data.
Right for having 500 users who joined at the same exact instant.
So we'd much rather spread them out so that we could try certain things with the data.
Play around with it.
So we're going to generate data using this.
So then the next logical question is OK we know how to generate a single email and a single date.
How do we do 500 of them.
And more importantly how the heck do we get them in a minuscule database.
So warning appear red letters.
This is not really code that will work well.
It's not code that will work that will work at all.
But I just want to show you.
We would want to do something like this right.
Insert into user's e-mail and create it at.
And the values you want a faker an Internet e-mail and fake or date date of past.
This is sort of a hybrid between my as well and node.
Unfortunately this doesn't work.
But this is what we're going for right.
We want to do something like this.
Insert 500 of these where we get a fake e-mail a fake date.
The problem is inserted into users.
This syntax only exists in my as well and faker only exists in node.
So how do we bridge that connection.
Oh and we want to use that 500 times.
Right.
The answer is that we use something called My.
Q Well and it's confusing because it's a node package like fakers and other package called my s.
Q Well what it does is it connects to my as.
Q Well the actual database and it talks to it.
So every language there are a couple of different packages.
You know PDP has a way of talking to mice.
Mice Well Ruby has a couple of ways.
They are kind of adapters.
Think of it as a connector between the two a tube or a pipeline and there's a couple for node but the
one we're using is the most popular It's called My as well which personally I find kind of confusing.
I wish it was called you know minuscule node or Maia's.
Q Well connecter or my s to LJ s or something.
And here's a couple of diagrams of basically how it works.
So we have node on unten.
This is where we've been working.
And then we have MY as well on its own our separate database.
So this has are data stored in it and the Maia's queue package will be able to say things like hey my
ask your database how many users are in there ask it to the database and then the my ask well database
will be able to say Well looks like there are currently 518 users send that back to node and we can
use it or might be something like this.
Hey there it is.
Q our database.
How many users are in there.
And my ask we all might say users.
I have no idea what you're talking about.
I don't have a users table in here in which case we would get that back to No.
Yes and we'd be able to know that because of the package we're using my s q our package is both asking
the questions.
All right it's querying the database and it's handling the replies.
So then in here we can write logic that says OK if we don't get a response if there's an error message
let's do one thing.
Otherwise do something else or a third scenario.
Hey there may as well our adaptor or my ass Our connector might ask how many users are in your database.
And there is no database.
We don't get a spot.
Well we need to figure out how to handle that node.
Unfortunately fortunately the my as well package handles that so it will you know start by freaking
out.
Are you there.
What's going on.
Bunch of sad faces but then they will figure it out.
It will basically time out and it will figure out there's no connection there's no database there.
And we'll be able to handle that as well which is something that could happen.
Your database server could go down.
Something could go wrong.
So these are different scenarios.
Mainly we're working with this one right where there's good communication and everything's working how
it should.
But the key thing is that the package my rescue package works in node talks to a database.
So without further ado let's see how that works.