接受带有id
的此代码:
router.post([Page].self, at: "/fetchStatusOfManagedReleases") { (req, pages) -> Future<[Page]> in
let eventIds = pages.map { $0.events }.flatMap { $0 }.map { $0.id }
return Release.query(on: req).filter(\.fbId ~~ eventIds).all().flatMap { releases in
let releaseInnerIds = releases.map {$0.id}
return TestPrice.query(on: req).filter(\.id ~~ releaseInnerIds).all().flatMap { testPrices in
return req.future([])
}
但是这里的releaseId
不是:
router.post([Page].self, at: "/fetchStatusOfManagedReleases") { (req, pages) -> Future<[Page]> in
let eventIds = pages.map { $0.events }.flatMap { $0 }.map { $0.id }
return Release.query(on: req).filter(\.fbId ~~ eventIds).all().flatMap { releases in
let releaseInnerIds = releases.map {$0.id}
return TestPrice.query(on: req).filter(\.releaseId ~~ releaseInnerIds).all().flatMap { testPrices in
return req.future([])
}
TestPrice模型:
final class TestPrice: Content {
var id: Int?
var price: String
var releaseId: Release.ID
init(id: Int?, price: String, releaseId: Release.ID) {
self.id = id
self.price = price
self.releaseId = releaseId
}
}
为什么?我需要做什么解决方法?