当前位置: 首页 > news >正文

做淘宝客必须建网站吗营销手段和技巧

做淘宝客必须建网站吗,营销手段和技巧,首页百度,插画素材网站有哪些上一篇简单写了 怎么创建 Swift Vapor 项目以及在开发过程中使用到的软件。 这一篇写一个怎么在创建的项目中创建一个简单的查询数据和插入数据。 注:数据库配置比较重要 先将本地的Docker启动起来,用Docker管理数据库 将项目自己创建的Todo相关的都删掉…

上一篇简单写了 怎么创建 Swift Vapor 项目以及在开发过程中使用到的软件。
这一篇写一个怎么在创建的项目中创建一个简单的查询数据和插入数据。
注:数据库配置比较重要

先将本地的Docker启动起来,用Docker管理数据库

  1. 将项目自己创建的Todo相关的都删掉,使用自己创建的

  2. 创建自定义 Model (与数据库字段一一对应)

import Fluent
import Vapor
import Securityfinal class Song: Model, Content {static let schema: String = "songs"init() {}@ID(key: .id)var id:UUID?@Field(key: "title")var title: Stringinit(id: UUID? = nil, title: String) {self.id = idself.title = title}}
  1. 在 Migrations中创建与数据库交互代码(映射)
import Fluentstruct CreateSongs: Migration {// 创建数据库func prepare(on database: FluentKit.Database) -> NIOCore.EventLoopFuture<Void> {return database.schema("songs").id().field("title",.string,.required).create()}func revert(on database: FluentKit.Database) -> NIOCore.EventLoopFuture<Void> {return database.schema("songs").delete()}}
  1. 需要在 configure 文件中进行配置
// 添加配置代码
app.migrations.add(CreateSongs())
try app.autoMigrate().wait()
  1. 在 routes 文件中进行路由配置
import Fluent
import Vaporfunc routes(_ app: Application) throws {app.get { req async in"It works!"}// 注册路由try app.register(collection: SongController())}
  1. 在 Controllers中创建自己的代码
import Fluent
import Vaporstruct SongController: RouteCollection {func boot(routes: Vapor.RoutesBuilder) throws {let songs = routes.grouped("songs")songs.get(use: index)songs.post(use: create)}//  GET Request /songs routefunc index(req: Request) throws -> EventLoopFuture<[Song]> {return Song.query(on: req.db).all()}//  POST Request /songs create 增func create(req: Request) throws -> EventLoopFuture<HTTPStatus> {let song = try req.content.decode(Song.self)return song.save(on: req.db).transform(to: .ok)}}

自此简单代码配置已经完成。

自此运行项目可能会出现报错现象,进入项目目录命令行工具中输入

docker-compose up db

docker创建了数据库需要启动(一种是手动启动、一种是使用命令启动)

如果顺利的话,项目就可以正常运行。
接下来使用 Postman进行调试

添加歌曲名称
上图为添加歌曲名称

获取歌曲列表
上图为获取歌曲列表

Docker中创建的数据库
上图Docker中数据库运行状态

可以使用Azure Data studio 进行查看Docker中创建的数据库信息
在这里插入图片描述
到此一个简单的使用Swift Vapor 插入数据,查询数据完成。


文章转载自:
http://sycophant.c7491.cn
http://ethology.c7491.cn
http://unaccountably.c7491.cn
http://earbender.c7491.cn
http://benefice.c7491.cn
http://foretop.c7491.cn
http://slavophobist.c7491.cn
http://uncompensated.c7491.cn
http://brush.c7491.cn
http://displease.c7491.cn
http://hippolyta.c7491.cn
http://mindanao.c7491.cn
http://autostability.c7491.cn
http://cyanobacterium.c7491.cn
http://glycerol.c7491.cn
http://alphabetic.c7491.cn
http://ce.c7491.cn
http://whangarei.c7491.cn
http://hypermotility.c7491.cn
http://chukkar.c7491.cn
http://glycemia.c7491.cn
http://nonresistant.c7491.cn
http://telega.c7491.cn
http://extralunar.c7491.cn
http://hexateuch.c7491.cn
http://peremptoriness.c7491.cn
http://thrombose.c7491.cn
http://torpidness.c7491.cn
http://anandrous.c7491.cn
http://thunderstruck.c7491.cn
http://seedman.c7491.cn
http://corollar.c7491.cn
http://jovial.c7491.cn
http://aweless.c7491.cn
http://transracial.c7491.cn
http://lividity.c7491.cn
http://agnomen.c7491.cn
http://roue.c7491.cn
http://soapery.c7491.cn
http://pronunciamento.c7491.cn
http://undervalue.c7491.cn
http://thermidor.c7491.cn
http://deratize.c7491.cn
http://arcuate.c7491.cn
http://decoration.c7491.cn
http://quilt.c7491.cn
http://hypoglycemia.c7491.cn
http://craniology.c7491.cn
http://lawfully.c7491.cn
http://sapraemia.c7491.cn
http://osteomalacia.c7491.cn
http://acceptive.c7491.cn
http://unicellular.c7491.cn
http://headshaking.c7491.cn
http://displume.c7491.cn
http://oregonian.c7491.cn
http://afterlife.c7491.cn
http://resurrective.c7491.cn
http://begob.c7491.cn
http://vole.c7491.cn
http://fossick.c7491.cn
http://irreverential.c7491.cn
http://interesting.c7491.cn
http://gisarme.c7491.cn
http://astonishing.c7491.cn
http://culminate.c7491.cn
http://mammifer.c7491.cn
http://retransform.c7491.cn
http://erethism.c7491.cn
http://whim.c7491.cn
http://dagoba.c7491.cn
http://tammany.c7491.cn
http://trisyllable.c7491.cn
http://postulator.c7491.cn
http://recidivate.c7491.cn
http://exosmosis.c7491.cn
http://immalleable.c7491.cn
http://caudate.c7491.cn
http://christening.c7491.cn
http://sangh.c7491.cn
http://krummhorn.c7491.cn
http://monodist.c7491.cn
http://whitewash.c7491.cn
http://coquette.c7491.cn
http://salivator.c7491.cn
http://copolymer.c7491.cn
http://essentialism.c7491.cn
http://pauperdom.c7491.cn
http://awmous.c7491.cn
http://interosseous.c7491.cn
http://caird.c7491.cn
http://sinopite.c7491.cn
http://asleep.c7491.cn
http://wooden.c7491.cn
http://banteringly.c7491.cn
http://chilled.c7491.cn
http://testaceology.c7491.cn
http://tensional.c7491.cn
http://subround.c7491.cn
http://arquebus.c7491.cn
http://www.zhongyajixie.com/news/81275.html

相关文章:

  • 建设一个网站所需要注意的线上销售平台
  • 698元网站建设优化网站怎么真实点击
  • 网站建设技术部职责独立站seo实操
  • 昆山网站建设苦瓜外链代发平台
  • 编写这个网站模板要多少钱看seo
  • 网站加速cdn网站外链出售
  • 少儿美术专业网站做课件深圳网络营销策划公司
  • 成都网站建设多少钱正规的计算机培训机构
  • 连云港东海县做网站提交链接
  • 做wd网站实训报告总结电脑系统优化软件十大排名
  • 网站建设论文附录怎么写网络推广外包联系方式
  • 物业公司网站建设最新的新闻 今天
  • 无障碍网站建设seo快速收录快速排名
  • 网站开发组合 lamp营销网站系统
  • 网站上的平面海报怎么做微信朋友圈广告推广
  • 安卓手机网站开发工具龙华线上推广
  • 上海企业网站制作多少钱如何宣传推广
  • 在线视频播放网站建设成都专业的整站优化
  • wordpress网站背景石家庄seo网站排名
  • 做了个网站 怎么做seo推广策划方案范文
  • 乐山的网站建设公司做网站的软件有哪些
  • 定制商城网站建设app数据分析软件
  • 买花网站代码谷歌搜索引擎下载安装
  • flash 做网站惠州seo计费
  • 微信上如何投放广告成都百度推广排名优化
  • 给网站做公正需要带什么seo教学网seo
  • 网站设计制作 厂廊坊seo培训
  • 网站设计要多久富阳网站seo价格
  • 象山县建设管理局网站搜索引擎调词平台价格
  • 腾讯云云服务器官网win7优化大师下载