蒸气可基于哪个字段进行过滤?

时间:2019-12-25 15:16:43

标签: swift vapor

接受带有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
    }
}

为什么?我需要做什么解决方法?

0 个答案:

没有答案