Defining Our User Data Model
When it comes to defining our user data model that is going to enable us to insert and get users from our database, we take the same approach that we did when creating our to-do item data model. This means we create a new user struct without an ID, and a user struct that has an ID due to it now being inserted in the database.
With our approach in mind, we can define the new user struct with the following code:
// nanoservices/auth/dal/src/users/schema.rs
use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct NewUser {
pub email: String,
pub password: String,
pub unique_id: String
}
We can see that we have a unique ID as well as a standard ID. Unique IDs become useful when you need to expose an ID to the outside world. For instance, if we wanted to make our users verify that the email address they provided was real, we could send an email with a link containing the unique ID for the user to click on. Once...