具有以下代码:
router.get("/fetchOngoingReleases", String.parameter) { (request) -> Future<[ReleaseWithUser]> in
return Release.query(on: request).filter(\.inProgress == true).all().flatMap { (ra) -> EventLoopFuture<[ReleaseWithUser]> in
let userId = try request.parameters.next(String.self)
return User.query(on: request).filter(\.fbId == userId).first().flatMap { (user) -> EventLoopFuture<[ReleaseWithUser]> in
let a = ra.map { (r) -> ReleaseWithUser in
// some condition and logic here
}
return a. //need this to make future
}
}
}
我检查了所有可能的方法调用,但没有将[ReleaseWithUser]
转换为Future<[ReleaseWithUser]>
。你有什么主意吗?
答案 0 :(得分:1)
解决方案是:
class Data: ObservableObject {
@Published var dataToUpdate: Int
}
struct UpdateView : View {
@EnvironmentObject data: Data
...body ... {
// use data.dataToUpdate here
}
}
可以使用ra.map { (r) -> ReleaseWithUser in
// some condition and logic here
}.flatten(on: request)
将数组转换为将来的数组。