VaporCountries

Vapor 包,用于向任何数据库添加国家和洲数据。

将其导入到您的项目中

let package = Package(
    name: "TestVaporCountries",
    dependencies: [      
      //VaporCountries
        .package(url: "https://github.com/mihaelamj/VaporCountries.git", from: "0.1.0")
  ],
    targets: [
      .target(name: "App", dependencies: ["FluentSQLite", "FluentMySQL", "FluentPostgreSQL", "VaporCountries"]),
  ]
)

用法(针对 MySQL)

import VaporCountries

// in configure.swift
migrations.addVaporCountries(for: .mysql)

//in routes.swift
try addVaporCountriesRoutes(for: .mysql, router: router)

用法(针对 PostgreSQL)

import VaporCountries

// in configure.swift
migrations.addVaporCountries(for: .psql)

//in routes.swift
try addVaporCountriesRoutes(for: .psql, router: router)

用法(针对 SQLite)

import VaporCountries

// in configure.swift
migrations.addVaporCountries(for: .sqlite)

//in routes.swift
try addVaporCountriesRoutes(for: .sqlite, router: router)

示例项目:https://github.com/mihaelamj/TestVaporCountries

关于制作新的 Vapor 包的教程文章:https://mihaelamj.github.io/Making%20a%20New%20Vapor%20Package/