User

We will be creating a user, so follow the steps given here:

  1. Create a User.swift file in Sources/App/Models/Database/ and enter the following content:
import Vaporimport Fluentfinal class User {        init() {    }        @ID(key: "id")    var id: Int?        @Field(key: "firstname")    var firstname: String?        @Field(key: "lastname")    var lastname: String?        @Field(key: "email")    var email: String        @Field(key: "password")    var password: String    }

Database models will always have to be final. The class as we wrote it now is—so far—only a regular Swift class that contains a few attributes. For now, we have entered the following:

  • id: A numeric number uniquely identifying the user.
  • firstname: The user's first name.
  • lastname: The user's last or family name.
  • email: The ...

Get Hands-On Swift 5 Microservices Development now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.