Update

public final class Update<T> : UpdateEndpoint where T : CorvusModel

A class that provides functionality to update objects of a generic type T conforming to CorvusModel and identified by a route parameter.

  • The return type of the .handler().

    Declaration

    Swift

    public typealias QuerySubject = T
  • The HTTP method for Update is PUT.

    Declaration

    Swift

    public let operationType: OperationType
  • Initializes the component with a given path parameter.

    Declaration

    Swift

    public init(_ id: PathComponent)

    Parameters

    id

    A PathComponent which represents the ID of the item to be deleted.

  • A method to find an item by an ID supplied in the Request.

    Throws

    An Abort error if the item is not found.

    Declaration

    Swift

    public func query(_ req: Request) throws -> QueryBuilder<QuerySubject>

    Parameters

    req

    An incoming Request.

    Return Value

    A QueryBuilder, which represents a Fluent query after having found the object with the supplied ID.

  • A method to update an item by an ID and new values supplied in the Request.

    Throws

    An Abort error if the item is not found.

    Declaration

    Swift

    public func handler(_ req: Request) throws ->
        EventLoopFuture<QuerySubject>

    Parameters

    req

    An incoming Request.

    Return Value

    An EventLoopFuture containing the updated value of the object of type QuerySubject.