support for update
This commit is contained in:
@@ -25,10 +25,23 @@ struct MatchController: RouteCollection {
|
||||
guard let id = req.parameters.get("id", as: UUID.self) else {
|
||||
throw Abort(.badRequest)
|
||||
}
|
||||
|
||||
let newMatch = try req.content.decode(Match.self)
|
||||
|
||||
return Match.find(id, on: req.db)
|
||||
.unwrap(or: Abort(.notFound))
|
||||
.flatMap { $0.update(on: req.db) }
|
||||
.flatMap {
|
||||
|
||||
|
||||
$0.update(newMatch: newMatch)
|
||||
|
||||
return $0.save(on: req.db)
|
||||
|
||||
}
|
||||
.map { .ok }
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
func deleteMatch(req: Request) throws -> EventLoopFuture<HTTPStatus> {
|
||||
|
||||
Reference in New Issue
Block a user