So before we can actually do much with our database connection pool that's now available to all of our
handlers, we need to describe our database in a format that Goh understands.
And that means setting out models, one model for each of the tables, at least that we have in our
schema.
So right now, let's just set one up for users.
So I'm going to go back to my ID and I will open up that package, which we called models, which is
right here.
And I'm going to describe my users table.
So I'll have a type called users and I will call it users with a capital use.
So it's available outside of this package.
It's just a struct.
And I have to describe every one of the fields in that table at least.
So I have it.
First name, last name, email.
Let's do those.
ID will be in it and I'll call it ID with a capital I.
So it's available outside of this package and it's an it.
And then we had first name, which I'm going to call, I'm going to name this way capital F, capital
M.
It's just a string and this is a convention to have the names of your members of the user type or the
fields of the users type correspond to the name that you actually use in the database.
But to use uppercase letters for the first part of each name and leave the underscores out.
So that's very conventional.
And then we had a last name, which is also a string.
We had email, which is also a string.
What else do we have?
Password created, updated up and access level.
So password, which is a string and access level, which is an entry and created at which is of type
time, dot time which is built into the the Go Standard Library and updated it, which is also of time
dot time.
All right.
So that describes our user table and I'll just call that users is the user model.
So there's one for users, what's our next one rooms, and it has ID room, name created, updated and
so type rooms, it's just a struct, it has an ID, which is an ENT.
It has room name, which is and string and that it has created and updated.
I'll just copy these.
And format it and give it a comment rooms is the room model.
Next, restrictions ID restriction name created an updated app that's almost the same, let's just copy
this and change the name restrictions plural one on.
Restriction model and its restriction name, I thought it was called Yepp, restriction name perfect.
Next, we have reservations type reservations struct.
It has an ID, which I'll just copy.
I shall just copy this and get rid of the middle.
So we have Idy first name, last name, email.
So first name, last name, I'll just copy these ones because I'm lazy.
Then email string, phone string, what else do we have a start date and date remedy
start date, which will be timed our time and date, which will be timed our time room ID, which will
be a hint.
What else do we have created an updated at already have those.
I do.
Now one other thing that we have we can do here.
We don't just have to put in the fields exactly as they exist in the database table.
We can also put other information.
For example, we have a remedy which implies that we also have a room associated with this.
So I can say room of type rooms.
That means I can actually include all of the room information right.
In this model if I want to.
I don't have to, but I can if I want to.
So let's give this its comment.
Reservations is the reservation model.
All right.
What's next?
Room restrictions, type room restrictions.
It's a struct it has an ID, which I'll copy.
And I know it has created an updated out, so let's copy those.
And what else do we have to start date and end date?
I can just copy those from here because I'm lazy.
And remedy someone has a remedy, which means it can also have a room, so I'll put that in there.
Reservation ID.
Which means I might want to put a reservation in here, so I'll call it reservation of type reservations.
Anything else, restriction?
Which can be a type restriction.
So restriction.
Restrictions now, I may not use restriction or reservation or room, but I want to be able to use them
easily if I have a need to do so.
So I'll add those types right on the model.
That way, if I when I'm pulling a room restriction, if I want to get all of the reservation ID information
and all of the restriction information and all the other information, I have somewhere to put it if
I need to.
Let's give this comment is the room restriction model.
All right.
So now we've set up our models and these will be useful to us as we begin to write our database methods,
which we will do in the next lecture.