蒸气过滤器在上下文中含糊不清

Vapor filters are ambiguous in context

为什么这在直接在 router.swift

中有效
router.delete("users", User.parameter, "books", Book.parameter, "favourite") { req -> Future<HTTPStatus> in
    try req.parameters.next(User.self).flatMap { user in
        try req.parameters.next(Book.self).flatMap { book in
            UserBookWatched.query(on: req).filter(\.userID == user.id!).filter(\.bookID == book.id!).first().flatMap { books in
                if let books = books {
                    return books.delete(on: req).transform(to: HTTPStatus.noContent)
                }

                return req.future().transform(to: HTTPStatus.notFound)
            }
        }
    }
}

并且这个在路由控制器中不起作用

// userid hardcoded, book from Book.parameter 
func removeBookFromFavourited(_ req: Request) throws -> Future<HTTPStatus> {
    let user = User(id: StaticUser.id)

    try req.parameters.next(Book.self).flatMap(to: HTTPStatus.self) { book in
        UserBookFavourited.query(on: req)
            .filter(\.userID == user.id!)
            .filter(\.bookID == book.id!)
            .first().flatMap { books in
            if let books = books {
                return books.delete(on: req).transform(to: HTTPStatus.noContent)
            }

            return req.future().transform(to: HTTPStatus.notFound)
        }
    }
}

它会删除 .filter(\.userID == user.id!) "Type of expression is ambiguous in this context"

的错误

模型被正确定义为枢轴

提前感谢帮助(edytowane) 静态用户将替换为请求中发送的 JWT 令牌 headers

错误太明显了...

缺少:RouteCollection 文件 header 中的 import Fluent