As we discussed in Chapter 2, Understanding Server-Side Swift, we are dealing with two types of models: database and input/output (I/O) models. You will now create both models and learn how to connect them to Fluent.
This PMS service features two models:
- Products
- Categories
Products are in categories, but in this (simplified) service, a product can only be in one category at a time. If you feel confident enough, you are welcome to extend this so that products could be in multiple categories.
In the next two sections, we will do the following:
- Create database models: the models we need to store our information in the database.
- Create I/O models: the models we need to take data in or return data to the client.
- Create the payload model: the model we need to work with our JWT.
Let's create the database models first.