The Shopping List Model

To create a Shopping List Model, all we need to do is inherit our class from the Model protocol, add a few methods that will be used to create an instance of that type using data from the database, and save the state of an instance into the database. Let's perform the following steps to create our first Shopping List Model in Vapor:

  1. Delete the Post.swift Model file included as part of our template project inside the Models folder. Also delete the PostController.swift inside the Controllers folder.
  2. Next open the Routes.swift file and remove all of the code inside of the setupRoutes() method as we will not be using the PostController in our app and any sample routes that are defined. Also open the Config+Setup.swift ...

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.