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 - Swift Tutorial
From the course: Using Vapor with SQL and NoSQL Databases
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
Overview of the Model protocol2m 53s
-
Implementing your Model5m 22s
-
Controller implementation7m 3s
-
CRUD operations6m 54s
-
Database preparation and reverting4m 33s
-
Working with dynamic Leaf templates6m 50s
-
Working with multipart form data, part 16m 30s
-
Working with multipart form data, part 24m 38s
-
-
-
-