1
00:00:00,420 --> 00:00:00,720
Okay.

2
00:00:00,720 --> 00:00:05,820
So what we're going to do now is start to prepare our data because I want to have what we call a database,

3
00:00:05,850 --> 00:00:10,530
cedar something, a script that we can run that will seed the database.

4
00:00:10,530 --> 00:00:15,720
We'll just add some some dummy data and we'll add the same stuff we have now these products.

5
00:00:15,720 --> 00:00:20,400
But we also need some users because products are going to be tied to a user.

6
00:00:20,670 --> 00:00:21,060
All right.

7
00:00:21,060 --> 00:00:29,670
So what we're going to do is still use this back end data folder and the products JS file.

8
00:00:29,670 --> 00:00:32,159
So this will be the data that we seed with.

9
00:00:32,159 --> 00:00:38,610
Now since we're using MongoDB or just about any database, when you insert a record, it automatically

10
00:00:38,610 --> 00:00:45,150
creates the ID, So we don't need these IDs, so let's just go ahead and get rid of these.

11
00:00:45,150 --> 00:00:47,820
So that's ID one, ID two.

12
00:00:48,850 --> 00:00:49,900
Three.

13
00:00:51,160 --> 00:00:52,120
For.

14
00:00:54,230 --> 00:00:54,950
Five.

15
00:00:54,950 --> 00:00:57,350
And I think we have six of these.

16
00:00:58,090 --> 00:01:01,360
Okay, So you should just have all the products minus the.

17
00:01:02,150 --> 00:01:13,370
The ID now we're going to have a user connected to these products, but we're going to do that in in

18
00:01:13,370 --> 00:01:15,500
the seed file or in the seed script.

19
00:01:15,500 --> 00:01:18,080
For now, let's just save what we have.

20
00:01:18,590 --> 00:01:21,650
And we can actually stop the server now.

21
00:01:21,650 --> 00:01:24,470
So save that products JS in the data folder.

22
00:01:24,470 --> 00:01:29,690
And now let's create another file in here called Users Dot.

23
00:01:29,690 --> 00:01:36,920
JS Okay, now this users file is going to hold three dummy users that we're going to create.

24
00:01:36,920 --> 00:01:43,280
So actually before we do that, we can't just store the plain password.

25
00:01:43,280 --> 00:01:49,310
And I want this cedar to work like as if a real user was registering.

26
00:01:49,310 --> 00:01:51,950
So the password would be hashed in that case.

27
00:01:51,950 --> 00:01:56,060
Now to hash passwords, we're going to be using a package called Bcrypt.

28
00:01:56,060 --> 00:02:01,130
JS So let's come down into the terminal, make sure you're in the root, not in the front end.

29
00:02:01,280 --> 00:02:07,940
We'll clear it up and let's do NPM install and then it's going to be Bcrypt JS.

30
00:02:09,690 --> 00:02:13,020
Okay, now that that's installed, I'm going to import bcrypt.

31
00:02:13,020 --> 00:02:18,150
So let's say import Bcrypt JS from Bcrypt.

32
00:02:18,150 --> 00:02:25,560
JS Actually, I'm sorry, it's just Bcrypt from Bcrypt JS and then let's create our users.

33
00:02:25,560 --> 00:02:33,990
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

34
00:02:33,990 --> 00:02:35,700
going to have one admin user.

35
00:02:35,700 --> 00:02:37,530
So this one will be admin.

36
00:02:37,530 --> 00:02:47,160
So we'll just give it a name of admin user and the email, let's say admin admin at email.

37
00:02:48,390 --> 00:02:52,050
Email.com and then the password.

38
00:02:52,050 --> 00:02:54,240
So the password for all of these users.

39
00:02:54,240 --> 00:02:57,270
I just want it to be one, two, three, four, five, six.

40
00:02:57,270 --> 00:03:01,170
But we don't want to just put this in as a string like that.

41
00:03:01,170 --> 00:03:05,010
Obviously we don't want plain text passwords even for these dummy users.

42
00:03:05,010 --> 00:03:12,390
So what we can do is wrap this in bcrypt dot and then hash sync.

43
00:03:13,070 --> 00:03:14,990
And then pass that in.

44
00:03:14,990 --> 00:03:24,470
And then it takes a second parameter, which is going to be the salt or um, yeah, let's see, generate

45
00:03:24,470 --> 00:03:26,840
salt to use default to ten.

46
00:03:27,020 --> 00:03:34,580
So basically the higher the number, the more secure the hash will be, but the longer it will take.

47
00:03:34,580 --> 00:03:36,080
So ten is a good number.

48
00:03:36,080 --> 00:03:38,300
I think it goes up to 20.

49
00:03:38,300 --> 00:03:40,340
So I think this is like right in the middle.

50
00:03:41,480 --> 00:03:41,810
Yeah.

51
00:03:41,810 --> 00:03:43,430
So that will hash the password.

52
00:03:43,430 --> 00:03:46,520
And then the last thing I want is the is admin.

53
00:03:46,520 --> 00:03:49,550
And I want that to be true for this particular user.

54
00:03:49,550 --> 00:03:52,430
And then we'll go ahead and just grab this.

55
00:03:52,610 --> 00:03:54,500
Let's copy it down twice.

56
00:03:54,500 --> 00:03:55,970
We just need our comma.

57
00:03:57,210 --> 00:03:57,660
Okay.

58
00:03:57,660 --> 00:04:04,050
And then the next the second user here, let's change to, let's say John Doe.

59
00:04:05,270 --> 00:04:11,750
Email will say, John at email, I want the same password, so we'll leave that and then is admin is

60
00:04:11,750 --> 00:04:13,790
going to be false in this case.

61
00:04:14,240 --> 00:04:14,630
Okay.

62
00:04:14,630 --> 00:04:19,190
And then we'll create our third user, which will be Jane Doe.

63
00:04:19,720 --> 00:04:23,560
And email will be Jane at email.

64
00:04:23,560 --> 00:04:26,980
Same password and false.

65
00:04:27,550 --> 00:04:29,140
As is admin.

66
00:04:29,620 --> 00:04:29,950
All right.

67
00:04:29,950 --> 00:04:31,660
And then we just need to export this.

68
00:04:31,660 --> 00:04:34,630
So let's say export default users.

69
00:04:35,570 --> 00:04:37,670
Now, we're not going to do orders.

70
00:04:37,670 --> 00:04:41,630
I'm not going to have any like order seating data.

71
00:04:41,630 --> 00:04:43,250
So I think this is good.

72
00:04:43,250 --> 00:04:49,130
So in the next video, what we're going to do is create our script to take these products and users

73
00:04:49,130 --> 00:04:51,320
and insert them into the database.

