[英]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.