From the course: Using Vapor with SQL and NoSQL Databases

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Implementing your Model

Implementing your Model - Swift Tutorial

From the course: Using Vapor with SQL and NoSQL Databases

Start my 1-month free trial

Implementing your Model

- [Instructor] Let's go ahead and create our model object. Going back to the theme of our project, we're going to be creating a blog, so the data that we're going to be looking to save are posts. But before we can continue, the first thing I'd like to do is come over here to our models directory and point out a file called Post.swift. This is the sample model object that was included with the basic Vapor template to demonstrate what a data model should look like. Also over here in the controller's folder, there's a file called PostController.swift that is meant to give a sample of what a controller looks like with all of it's saving and displaying functionality. However, let's go ahead and delete both of these files. As we're going to be building our own, from the ground up, so that we can fully understand these concepts. Now that we've deleted these files, I'm going to come over here to my terminal window and I'm in my project directory. I want to create my model object, so I'm going…

Contents