From 5ef8bfe380b1395bfecc985835dde1cd89deb07a Mon Sep 17 00:00:00 2001 From: tanner0101 Date: Mon, 3 Apr 2017 12:58:07 +0200 Subject: [PATCH] mysql --- 2.0/docs/fluent/package.md | 5 +++- 2.0/docs/index.md | 3 ++ 2.0/docs/mysql/package.md | 60 ++++++++++++++++++++++++++++++++++++++ 2.0/mkdocs.yml | 2 ++ 4 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 2.0/docs/mysql/package.md diff --git a/2.0/docs/fluent/package.md b/2.0/docs/fluent/package.md index 045266ab..0fc120fa 100644 --- a/2.0/docs/fluent/package.md +++ b/2.0/docs/fluent/package.md @@ -21,7 +21,7 @@ let package = Package( The Fluent provider package adds Fluent to your project and adds some additional, Vapor-specific conveniences like HTTP conformances. -Using `import VaporFluent` will import both Fluent and Fluent's Vapor-specific APIs. +Using `import FluentProvider` will import both Fluent and Fluent's Vapor-specific APIs. ## Without Vapor @@ -45,3 +45,6 @@ Use `import Fluent` to access Fluent's APIs. !!! warning `Model` is a Vapor + Fluent type, use `Entity` instead. +## Drivers + +Fluent drivers allow Fluent models and queries to communicate with various database technologies like MySQL or Mongo. For a full list of drivers, check out the [`fluent-driver`](https://github.com/search?utf8=✓&q=topic%3Afluent-driver&type=Repositories) tag on GitHub. diff --git a/2.0/docs/index.md b/2.0/docs/index.md index 52790263..64c13915 100644 --- a/2.0/docs/index.md +++ b/2.0/docs/index.md @@ -109,6 +109,9 @@ These are packages created by community members that work great with Vapor. - [Jobs](https://github.com/BrettRToomey/Jobs): A minimalistic job/background-task system for Swift. - [Heimdall](https://github.com/himani93/heimdall): An easy to use HTTP request logger. +### Providers + +Vapor providers are a convenient way to add functionality to your Vapor projects. For a full list of providers, check out the [`vapor-provider`](https://github.com/search?utf8=✓&q=topic%3Avapor-provider&type=Repositories) tag on GitHub. ## Authors diff --git a/2.0/docs/mysql/package.md b/2.0/docs/mysql/package.md new file mode 100644 index 00000000..433af1f0 --- /dev/null +++ b/2.0/docs/mysql/package.md @@ -0,0 +1,60 @@ +# Using MySQL + +This section outlines how to import the MySQL package both with or without a Vapor project. + +## With Vapor + +The easiest way to use MySQL with Vapor is to include the MySQL provider. + +```swift +import PackageDescription + +let package = Package( + name: "Project", + dependencies: [ + .Package(url: "https://github.com/vapor/vapor.git", majorVersion: 2), + .Package(url: "https://github.com/vapor/mysql-provider.git", majorVersion: 2) + ], + exclude: [ ... ] +) +``` + +The MySQL provider package adds MySQL to your project and adds some additional, Vapor-specific conveniences like `drop.mysql()`. + +Using `import MySQLProvider` will import both Fluent and Fluent's Vapor-specific APIs. + +## With Fluent + +Fluent is a powerful, pure-Swift ORM that can be used with any Server-Side Swift framework. The MySQL driver allows you to use a MySQL database to power your models and queries. + +```swift +import PackageDescription + +let package = Package( + name: "Project", + dependencies: [ + ... + .Package(url: "https://github.com/vapor/mysql-driver.git", majorVersion: 2) + ], + exclude: [ ... ] +) +``` + +Use `import MySQLDriver` to access the `MySQLDriver` class which you can use to initialize a Fluent `Database`. + +## Just MySQL + +At the core of the MySQL provider and MySQL driver is a Swift wrapper around the C MySQL client. This package can be used by itself to send raw, parameterized queries to your MySQL database. + +```swift +import PackageDescription + +let package = Package( + name: "Project", + dependencies: [ + ... + .Package(url: "https://github.com/vapor/mysql.git", majorVersion: 2) + ], + exclude: [ ... ] +) +``` diff --git a/2.0/mkdocs.yml b/2.0/mkdocs.yml index 13f4f1c7..f57ecb62 100644 --- a/2.0/mkdocs.yml +++ b/2.0/mkdocs.yml @@ -38,6 +38,8 @@ pages: - 'Query': 'fluent/query.md' - 'Relation': 'fluent/relation.md' - 'Package': 'fluent/package.md' +- MySQL: + - 'Package': 'mysql/package.md' - Auth: - 'Getting Started': 'auth/getting-started.md' - 'Helper': 'auth/helper.md'