Creating our user model
Since we are managing user sessions in our app, we will need to store information about our users to check their credentials, before we allow our to-do items to be created, deleted, and edited. We will store our user data in a PostgreSQL database. While this is not essential, we will also link users in the database to to-do items. This will give us an understanding of how to alter an existing table and create links between tables. To create our user model, we are going to have to do the following:
- Create a
User
data model. - Create a
NewUser
data model. - Alter the to-do item data model so that we can link it to a user model.
- Update the schema file with the new table and altered fields.
- Create and run migration scripts on the database.
In the following sections, we’ll look at the preceding steps in detail.
Creating a User data module
Before we start, we will need to update the dependencies in the Cargo.toml
file with the...