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.

Setup overview

Setup overview - Swift Tutorial

From the course: Using Vapor with SQL and NoSQL Databases

Start my 1-month free trial

Setup overview

- When working with databases in Vapor, there are essentially three steps that you have to do to set your project up. First, you'll need to make sure that your database of choice is installed on your machine. In this course, we'll be using PostgreSQL. However, it's very easy to switch between other database solutions, such as MySQL or MongoDB with just a few lines of code, as you'll see later on in this course. Secondly, you'll need to add your Provider to your Vapor project. To do this, you'll want to go to the Vapor GitHub page, search for your Provider, and copy the URL to its GitHub repository. Then, you're going to add it as a dependency to your Package.swift file. Lastly you want to add your database driver to your Vapor project, which you do in your main .swift file when you declare your Droplet. First, you're going to import your Provider. Then, when initializing your Droplet, you're going to add in a parameter for your database Provider. Now that we have an understanding of…

Contents