终端find 命令行可用于查找 Spotlight Search 无法找到的“data.sqlite”(或其他已知数据库名称)文件:
sudo find / -name "data.sqlite" -print
在 Vapor 2 中,SQLite 是 Fluent 的一部分,因此不再需要 SQLiteProvider。使用SQLiteProvider 的教程将改为使用FluentProvider。
对于 Vapor 2 默认的api 模板,包含Fluent。对于 Vapor 2 非默认的web 模板,需要将fluent-provider 添加到Package.swift 并随后在代码中进行配置。
对于swift package tools-version 3.1.0
dependencies: [
…
.Package(url: "https://github.com/vapor/fluent-provider.git", majorVersion: 1),
对于swift package tools-version4.0.0
dependencies: [
…
.package(url: "https://github.com/vapor/fluent-provider.git", .upToNextMajor(from: "1.3.0")),
我发现为 Vapor 2 生成 SQLite 文件的位置如下...
vapor --version
# Vapor Toolbox: 2.0.3
# Vapor Framework: 2.1.0
vapor new VaporDefaultExample
cd VaporDefaultExample/Config
nano fluent.json # edit to: "driver": "sqlite"
nano sqlite.json # create file. add { "path":"FindMeSQLite.sqlite" }
请注意,Config/sqlite.json 文件中指定了预期的 .sqlite 位置。
cd ..
vapor update
vapor build
vapor run &
sudo find / -name "FindMeSQLite.sqlite" -print
结果:在Config/sqlite.json 中指定的路径/to/VaporDefaultExample/FindMeSQLite.sqlite 中找到“FindMeSQLite.sqlite”
# ^C quit the previous vapor run
# then create Xcode project
vapor xcode -y
# run project in Xcode
# then, repeat the find
sudo find / -name "FindMeSQLite.sqlite" -print
结果:“FindMeSQLite.sqlite”再次在path/to/VaporDefaultExample/FindMeSQLite.sqlite 找到,如Config/sqlite.json 中指定的那样
注意:如果 .sqlite 位置与您的配置不同,那么 macOS 或 Ubuntu 上的 find 应该显示这样的位置。