ReadAll

public final class ReadAll<T> : ReadEndpoint where T : CorvusModel

A class that provides functionality to read all objects of a generic type T conforming to CorvusModel.

  • The return type of the .query().

    Declaration

    Swift

    public typealias QuerySubject = T
  • The return type of the .handler().

    Declaration

    Swift

    public typealias Element = [T]
  • A property that describes if only existing, only trashed or both objects should be read from the database.

    Declaration

    Swift

    public let target: ReadTarget<QuerySubject>
  • The default operationType is GET.

    Declaration

    Swift

    public var operationType: OperationType { get }
  • Initializes the component

    Declaration

    Swift

    public init(_ target: ReadTarget<QuerySubject> = .existing)

    Parameters

    target

    A ReadTarget which controls where to query the item from.

  • A method to return all objects of the type QuerySubject from the database, depending on the target.

    Throws

    An Abort error if something goes wrong.

    Declaration

    Swift

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

    Parameters

    req

    An incoming Request.

    Return Value

    An array of QuerySubjects.

  • A modifier used to make sure components only authorize requests where the supplied user U is actually related to the QuerySubject.

    Declaration

    Swift

    public func auth<I: CorvusModel, U: CorvusModelAuthenticatable> (
        _ intermediate: NestedReadAllAuthModifier<ReadAll, I, U>
        .IntermediateKeyPath,
        _ user: NestedReadAllAuthModifier<ReadAll, I, U>.UserKeyPath
    ) -> NestedReadAllAuthModifier<ReadAll, I, U>

    Parameters

    intermediate

    A KeyPath to the intermediate property.

    user

    A KeyPath to the related user property from the intermediate.

    Return Value

    An instance of a AuthModifier with the supplied KeyPath to the user.

  • A modifier used to make sure components only authorize requests where the supplied user U is actually related to the QuerySubject.

    Declaration

    Swift

    public func auth<U: CorvusModelAuthenticatable> (
        _ user: ReadAllAuthModifier<ReadAll, U>.UserKeyPath
    ) -> ReadAllAuthModifier<ReadAll, U>

    Parameters

    user

    A KeyPath to the related user property from the intermediate.

    Return Value

    An instance of a AuthModifier with the supplied KeyPath to the user.