Okay.
So what we're going to do now is start to prepare our data because I want to have what we call a database,
cedar something, a script that we can run that will seed the database.
We'll just add some some dummy data and we'll add the same stuff we have now these products.
But we also need some users because products are going to be tied to a user.
All right.
So what we're going to do is still use this back end data folder and the products JS file.
So this will be the data that we seed with.
Now since we're using MongoDB or just about any database, when you insert a record, it automatically
creates the ID, So we don't need these IDs, so let's just go ahead and get rid of these.
So that's ID one, ID two.
Three.
For.
Five.
And I think we have six of these.
Okay, So you should just have all the products minus the.
The ID now we're going to have a user connected to these products, but we're going to do that in in
the seed file or in the seed script.
For now, let's just save what we have.
And we can actually stop the server now.
So save that products JS in the data folder.
And now let's create another file in here called Users Dot.
JS Okay, now this users file is going to hold three dummy users that we're going to create.
So actually before we do that, we can't just store the plain password.
And I want this cedar to work like as if a real user was registering.
So the password would be hashed in that case.
Now to hash passwords, we're going to be using a package called Bcrypt.
JS So let's come down into the terminal, make sure you're in the root, not in the front end.
We'll clear it up and let's do NPM install and then it's going to be Bcrypt JS.
Okay, now that that's installed, I'm going to import bcrypt.
So let's say import Bcrypt JS from Bcrypt.
JS Actually, I'm sorry, it's just Bcrypt from Bcrypt JS and then let's create our users.
So we'll say const users and set that to an array and then each user is going to have a name and I'm
going to have one admin user.
So this one will be admin.
So we'll just give it a name of admin user and the email, let's say admin admin at email.
Email.com and then the password.
So the password for all of these users.
I just want it to be one, two, three, four, five, six.
But we don't want to just put this in as a string like that.
Obviously we don't want plain text passwords even for these dummy users.
So what we can do is wrap this in bcrypt dot and then hash sync.
And then pass that in.
And then it takes a second parameter, which is going to be the salt or um, yeah, let's see, generate
salt to use default to ten.
So basically the higher the number, the more secure the hash will be, but the longer it will take.
So ten is a good number.
I think it goes up to 20.
So I think this is like right in the middle.
Yeah.
So that will hash the password.
And then the last thing I want is the is admin.
And I want that to be true for this particular user.
And then we'll go ahead and just grab this.
Let's copy it down twice.
We just need our comma.
Okay.
And then the next the second user here, let's change to, let's say John Doe.
Email will say, John at email, I want the same password, so we'll leave that and then is admin is
going to be false in this case.
Okay.
And then we'll create our third user, which will be Jane Doe.
And email will be Jane at email.
Same password and false.
As is admin.
All right.
And then we just need to export this.
So let's say export default users.
Now, we're not going to do orders.
I'm not going to have any like order seating data.
So I think this is good.
So in the next video, what we're going to do is create our script to take these products and users
and insert them into the database.