Restore

public final class Restore<T> : AuthEndpoint where T : CorvusModel

A class that provides functionality to restore soft-deleted 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 return type of the .query().

    Declaration

    Swift

    public typealias Element = HTTPStatus
  • The HTTP operation type of the component.

    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.

  • A method to find a soft-deleted 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 return an object found in the .query() from the database.

    Throws

    An Abort error if something goes wrong.

    Declaration

    Swift

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

    Parameters

    req

    An incoming Request.

    Return Value

    A HTTPStatus of either .ok, when the object was successfully deleted, or .notFound, when the object was not found.

  • A method that registers the .handler() to the supplied RoutesBuilder.

    Declaration

    Swift

    public func register(to routes: RoutesBuilder)

    Parameters

    routes

    A RoutesBuilder containing all the information about the HTTP route leading to the current component.