This commit is contained in:
tanner0101 2017-04-03 12:58:07 +02:00
parent 906c0f72cc
commit 5ef8bfe380
4 changed files with 69 additions and 1 deletions

View File

@ -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.

View File

@ -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

60
2.0/docs/mysql/package.md Normal file
View File

@ -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: [ ... ]
)
```

View File

@ -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'