Getting started with the User model

Great! Now that we have AuthProvider added to the project, we can build and run our app to confirm we have imported it correctly. Now, let's go ahead and define our User model next:

  1. Create a new file called User.swift inside the Models folder in your Vapor app and make sure that you check App under Targets:
  1. Inside this file, delete all of the sample code and import the following dependencies:
import FluentProviderimport HTTPimport Fluentimport AuthProvider
  1. Next, define the class, and we will make it implement both the Model and SessionPersistable protocols:
final class User: Model, SessionPersistable ...

Get Hands-On Full-Stack Development with Swift now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.