繁体   English   中英

在 Vapor 命令中使用 Fluent

[英]Using Fluent in a Vapor Command

我正在尝试在命令中使用 Fluent,但我遇到了这个问题:

在这个查询中:

let location: Location? = try? Location.query(on: context.application.db).filter(\.geId == 123).first().wait()

我明白了: Type of expression is ambiguous without more context"


当我删除过滤器时,一切都很好:

let location: Location? = try? Location.query(on: context.application.db).first().wait()

当我使 var 非可选时:

let location: Location = try? Location.query(on: context.application.db).filter(\.geId == 123).first().wait()

我得到: Cannot convert value of type 'Location?' to specified type 'Location' Cannot convert value of type 'Location?' to specified type 'Location'

相同的查询正在使用flatMap而不是wait()处理 Route

所以,我有点困惑。 我的错误在哪里?

这是一个简单的...只是错过了

import Fluent

感谢 Discord 的@0xTim :)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM