[英]Using Fluent in a Vapor Command
I'm trying to use Fluent in a Command and I have this problem:我正在尝试在命令中使用 Fluent,但我遇到了这个问题:
On this query:在这个查询中:
let location: Location? = try? Location.query(on: context.application.db).filter(\.geId == 123).first().wait()
I get: Type of expression is ambiguous without more context"
我明白了:
Type of expression is ambiguous without more context"
When I remove the filter, everything is fine:当我删除过滤器时,一切都很好:
let location: Location? = try? Location.query(on: context.application.db).first().wait()
When I make the var non optional:当我使 var 非可选时:
let location: Location = try? Location.query(on: context.application.db).filter(\.geId == 123).first().wait()
I get: Cannot convert value of type 'Location?' to specified type 'Location'
我得到:
Cannot convert value of type 'Location?' to specified type 'Location'
Cannot convert value of type 'Location?' to specified type 'Location'
The same query is working on a Route with flatMap instead of the wait()相同的查询正在使用flatMap而不是wait()处理 Route
So, I'm a bit confused.所以,我有点困惑。 Where ist my error?
我的错误在哪里?
This was a simple one... Just missing the这是一个简单的...只是错过了
import Fluent
Thanks to @0xTim at Discord:)感谢 Discord 的@0xTim :)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.