0x00 Chapter 6:Configuring a Database
1.Vapor
has official, Swift-native drivers
for:
- SQLite
- MySQL
- PostgreSQL
- MongoDB
2.数据库类型:
关系型(relational):MySQL
and PostgreSQL
非关系型(non-relational):MongoDB
SQLite
是一个简单的、基于文件
的关系数据库系统。
它旨在嵌入到应用程序中,对于单进程应用程序(例如 iOS 应用程序)很有用
MySQL
become the most popular
database due to its ease of use
and support from most cloud providers and website builders
PostgreSQL
专为企业
使用而设计。还原生支持几何图元,例如坐标
MongoDB
旨在处理大量非结构化
数据并具有极高的可扩展性
3.使用 SQLite
,需要的配置
SQLite
doesn’t require you to run a database server
since SQLite uses a local
file
Package.swift
文件的配置
a.添加依赖
dependencies: [
.package(url: "https://github.com/vapor/fluent-sqlite-driver.git", from: "4.0.0")
]
b.给名为 App
的 target
添加依赖:
dependencies: [
.product(name: "FluentSQLiteDriver", package: "fluent-sqlite-driver")
]
完整的内容:
// swift-tools-version:5.5
import PackageDescription
let package = Package(
name: "TILApp",
platforms: [
.macOS(.v12)
],
dependencies: [
// 标签:Chapter,vapor,name,Configuring,package,DATABASE,driver,dependencies,Vapor From: https://blog.51cto.com/u_15844020/5791289