1
00:00:01,020 --> 00:00:06,450
So before we can actually do much with our database connection pool that's now available to all of our

2
00:00:06,450 --> 00:00:11,610
handlers, we need to describe our database in a format that Goh understands.

3
00:00:11,820 --> 00:00:18,060
And that means setting out models, one model for each of the tables, at least that we have in our

4
00:00:18,060 --> 00:00:18,420
schema.

5
00:00:18,780 --> 00:00:21,030
So right now, let's just set one up for users.

6
00:00:21,060 --> 00:00:28,620
So I'm going to go back to my ID and I will open up that package, which we called models, which is

7
00:00:28,620 --> 00:00:29,130
right here.

8
00:00:29,970 --> 00:00:32,460
And I'm going to describe my users table.

9
00:00:32,580 --> 00:00:36,900
So I'll have a type called users and I will call it users with a capital use.

10
00:00:36,900 --> 00:00:38,730
So it's available outside of this package.

11
00:00:39,120 --> 00:00:40,170
It's just a struct.

12
00:00:40,290 --> 00:00:44,250
And I have to describe every one of the fields in that table at least.

13
00:00:44,940 --> 00:00:45,990
So I have it.

14
00:00:45,990 --> 00:00:47,330
First name, last name, email.

15
00:00:47,340 --> 00:00:47,940
Let's do those.

16
00:00:48,630 --> 00:00:52,850
ID will be in it and I'll call it ID with a capital I.

17
00:00:52,950 --> 00:00:56,370
So it's available outside of this package and it's an it.

18
00:00:57,120 --> 00:01:02,460
And then we had first name, which I'm going to call, I'm going to name this way capital F, capital

19
00:01:02,460 --> 00:01:02,820
M.

20
00:01:02,820 --> 00:01:08,520
It's just a string and this is a convention to have the names of your members of the user type or the

21
00:01:08,520 --> 00:01:13,020
fields of the users type correspond to the name that you actually use in the database.

22
00:01:13,320 --> 00:01:18,630
But to use uppercase letters for the first part of each name and leave the underscores out.

23
00:01:18,690 --> 00:01:19,740
So that's very conventional.

24
00:01:20,070 --> 00:01:22,440
And then we had a last name, which is also a string.

25
00:01:23,190 --> 00:01:25,460
We had email, which is also a string.

26
00:01:25,530 --> 00:01:26,300
What else do we have?

27
00:01:27,780 --> 00:01:30,510
Password created, updated up and access level.

28
00:01:31,140 --> 00:01:43,110
So password, which is a string and access level, which is an entry and created at which is of type

29
00:01:43,110 --> 00:01:52,380
time, dot time which is built into the the Go Standard Library and updated it, which is also of time

30
00:01:52,380 --> 00:01:53,070
dot time.

31
00:01:55,980 --> 00:01:56,400
All right.

32
00:01:56,970 --> 00:02:04,230
So that describes our user table and I'll just call that users is the user model.

33
00:02:07,140 --> 00:02:14,020
So there's one for users, what's our next one rooms, and it has ID room, name created, updated and

34
00:02:14,040 --> 00:02:20,130
so type rooms, it's just a struct, it has an ID, which is an ENT.

35
00:02:20,700 --> 00:02:26,160
It has room name, which is and string and that it has created and updated.

36
00:02:26,190 --> 00:02:27,330
I'll just copy these.

37
00:02:30,040 --> 00:02:37,480
And format it and give it a comment rooms is the room model.

38
00:02:40,600 --> 00:02:47,110
Next, restrictions ID restriction name created an updated app that's almost the same, let's just copy

39
00:02:47,110 --> 00:02:54,610
this and change the name restrictions plural one on.

40
00:02:59,090 --> 00:03:07,790
Restriction model and its restriction name, I thought it was called Yepp, restriction name perfect.

41
00:03:08,510 --> 00:03:16,310
Next, we have reservations type reservations struct.

42
00:03:16,910 --> 00:03:18,650
It has an ID, which I'll just copy.

43
00:03:18,780 --> 00:03:20,510
I shall just copy this and get rid of the middle.

44
00:03:24,330 --> 00:03:27,480
So we have Idy first name, last name, email.

45
00:03:28,020 --> 00:03:30,900
So first name, last name, I'll just copy these ones because I'm lazy.

46
00:03:34,840 --> 00:03:43,900
Then email string, phone string, what else do we have a start date and date remedy

47
00:03:47,860 --> 00:03:58,990
start date, which will be timed our time and date, which will be timed our time room ID, which will

48
00:03:58,990 --> 00:03:59,740
be a hint.

49
00:04:00,940 --> 00:04:04,990
What else do we have created an updated at already have those.

50
00:04:05,000 --> 00:04:05,500
I do.

51
00:04:05,980 --> 00:04:07,990
Now one other thing that we have we can do here.

52
00:04:08,110 --> 00:04:15,250
We don't just have to put in the fields exactly as they exist in the database table.

53
00:04:15,260 --> 00:04:16,750
We can also put other information.

54
00:04:16,760 --> 00:04:21,730
For example, we have a remedy which implies that we also have a room associated with this.

55
00:04:21,730 --> 00:04:24,760
So I can say room of type rooms.

56
00:04:26,440 --> 00:04:29,980
That means I can actually include all of the room information right.

57
00:04:29,980 --> 00:04:31,480
In this model if I want to.

58
00:04:31,480 --> 00:04:33,220
I don't have to, but I can if I want to.

59
00:04:33,820 --> 00:04:35,290
So let's give this its comment.

60
00:04:37,990 --> 00:04:40,930
Reservations is the reservation model.

61
00:04:41,620 --> 00:04:41,920
All right.

62
00:04:41,920 --> 00:04:42,520
What's next?

63
00:04:42,910 --> 00:04:48,460
Room restrictions, type room restrictions.

64
00:04:49,060 --> 00:04:52,090
It's a struct it has an ID, which I'll copy.

65
00:04:53,900 --> 00:04:57,820
And I know it has created an updated out, so let's copy those.

66
00:05:01,210 --> 00:05:02,910
And what else do we have to start date and end date?

67
00:05:02,920 --> 00:05:05,410
I can just copy those from here because I'm lazy.

68
00:05:09,390 --> 00:05:18,320
And remedy someone has a remedy, which means it can also have a room, so I'll put that in there.

69
00:05:23,000 --> 00:05:24,170
Reservation ID.

70
00:05:29,020 --> 00:05:33,910
Which means I might want to put a reservation in here, so I'll call it reservation of type reservations.

71
00:05:37,270 --> 00:05:38,890
Anything else, restriction?

72
00:05:45,770 --> 00:05:47,510
Which can be a type restriction.

73
00:05:50,150 --> 00:05:51,110
So restriction.

74
00:05:54,140 --> 00:06:00,620
Restrictions now, I may not use restriction or reservation or room, but I want to be able to use them

75
00:06:00,620 --> 00:06:02,680
easily if I have a need to do so.

76
00:06:02,780 --> 00:06:04,910
So I'll add those types right on the model.

77
00:06:04,940 --> 00:06:10,950
That way, if I when I'm pulling a room restriction, if I want to get all of the reservation ID information

78
00:06:10,950 --> 00:06:15,140
and all of the restriction information and all the other information, I have somewhere to put it if

79
00:06:15,140 --> 00:06:15,720
I need to.

80
00:06:16,220 --> 00:06:22,640
Let's give this comment is the room restriction model.

81
00:06:23,120 --> 00:06:23,570
All right.

82
00:06:23,690 --> 00:06:29,150
So now we've set up our models and these will be useful to us as we begin to write our database methods,

83
00:06:29,150 --> 00:06:31,220
which we will do in the next lecture.
