postgresql – 在顶级引发的错误:Fluent.EntityError.noDatabase

postgresql – 在顶级引发的错误:Fluent.EntityError.noDatabase,第1张

概述我正在尝试修复我最近在运行Vapor项目时遇到的错误. 它构建良好,但当它运行时,它崩溃.这是我的日志: fatal error: Error raised at top level: Fluent.EntityError.noDatabase: file /Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-800.0.58.6/sr 我正在尝试修复我最近在运行Vapor项目时遇到的错误.

它构建良好,但当它运行时,它崩溃.这是我的日志:

Fatal error: Error raised at top level: Fluent.EntityError.noDatabase: file /library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-800.0.58.6/src/swift/stdlib/public/core/ErrorType.swift,line 184Current stack trace:0    libswiftCore.dylib                 0x0000000100fe7cc0 swift_reportError + 1321    libswiftCore.dylib                 0x0000000101004f50 _swift_stdlib_reportFatalErrorInfile + 1122    libswiftCore.dylib                 0x0000000100fb3370 partial apply for (_assertionFailed(StaticString,String,StaticString,UInt,flags : UInt32) -> Never).(closure #1).(closure #1).(closure #1) + 993    libswiftCore.dylib                 0x0000000100dfb0a0 specialized specialized StaticString.withUTF8Buffer<A> ((UnsafeBufferPointer<UInt8>) -> A) -> A + 3554    libswiftCore.dylib                 0x0000000100fb32b0 partial apply for (_assertionFailed(StaticString,flags : UInt32) -> Never).(closure #1).(closure #1) + 1445    libswiftCore.dylib                 0x0000000100dfb5b0 specialized specialized String._withUnsafeBufferPointerToUTF8<A> ((UnsafeBufferPointer<UInt8>) throws -> A) throws -> A + 1246    libswiftCore.dylib                 0x0000000100f57af0 partial apply for (_assertionFailed(StaticString,flags : UInt32) -> Never).(closure #1) + 1857    libswiftCore.dylib                 0x0000000100dfb0a0 specialized specialized StaticString.withUTF8Buffer<A> ((UnsafeBufferPointer<UInt8>) -> A) -> A + 3558    libswiftCore.dylib                 0x0000000100dfae80 _assertionFailed(StaticString,flags : UInt32) -> Never + 1449    libswiftCore.dylib                 0x0000000100e1e540 swift_unexpectedError_merged + 56910   App                                0x0000000100001ef0 main + 279811   libdyld.dylib                      0x00007fff974375ac start + 1Program ended with exit code: 9

我正在使用VaporPostgresql包.这是我的Package.swift:

import PackageDescriptionlet package = Package(    name: "mist",dependencIEs: [        .Package(url: "https://github.com/vapor/vapor.git",majorVersion: 1,minor: 2),.Package(url: "https://github.com/vapor/postgresql-provIDer.git",minor: 1)    ],exclude: [        "Config","Database","Localization","Public","Resources","Tests",])

和main.swift:

import Vaporimport VaporPostgresqlimport Authimport httplet drop = Droplet()let auth = AuthMIDdleware(user: User.self)try drop.addProvIDer(VaporPostgresql.ProvIDer.self)drop.preparations.append(Post.self)drop.preparations.append(User.self)drop.preparations.append(Site.self)drop.mIDdleware.append(auth)let admin = adminController()var site = Site(name: "",theme: "")if let retreivedSite = try Site.all().first {    site = retreivedSite} else {    drop.get { req in        return Response(redirect: "http://localhost:8080/login")    }}drop.get { req in    return try drop.vIEw.make("themes/VaporDark/index",[        "posts": Node(node: JsON(Post.all().makeNode()))    ])}admin.addRoutes(to: drop)drop.resource("posts",PostController())drop.run()

我的postgres版本是9.6.1

出于某种原因,VaporPostgresql不会更新,我认为这可能是问题的一部分.我已经尝试过蒸汽xcode,蒸汽构造和蒸汽清洁,但我无法获得最新版本.

解决方法 我认为这个问题在这里:

if let retreivedSite = try Site.all().first {    site = retreivedSite} else {    drop.get { req in        return Response(redirect: "http://localhost:8080/login")    }}

更具体地说,Site.all()调用.在调用run()命令之前,我们不准备模型,因此,要在该点之前查找Site,需要手动准备模型.

希望这可以帮助!

总结

以上是内存溢出为你收集整理的postgresql – 在顶级引发的错误:Fluent.EntityError.noDatabase全部内容,希望文章能够帮你解决postgresql – 在顶级引发的错误:Fluent.EntityError.noDatabase所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/1156746.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-01
下一篇 2022-06-01

发表评论

登录后才能评论

评论列表(0条)

保存