ChildrenModifier

public final class ChildrenModifier<
    R: ReadEndpoint,
    M: CorvusModel>:
ReadEndpoint

A class that wraps a component which utilizes a .children() modifier. That allows Corvus to chain modifiers, as it gets treated as any other struct conforming to ReadEndpoint.

  • The type of the value loaded with the .children() modifier.

    Declaration

    Swift

    public typealias Element = [M]
  • The return value of the .handler(), so the type being operated on in the current component.

    Declaration

    Swift

    public typealias QuerySubject = M
  • The type being operated on by the prior component in the modifier chain.

    Declaration

    Swift

    public typealias ParentQuerySubject = R.QuerySubject
  • The KeyPath to the related attribute of the QuerySubject that is to be loaded.

    Declaration

    Swift

    public typealias ChildrenPath = KeyPath<
        ParentQuerySubject, ParentQuerySubject.Children<M>
    >
  • Initializes the modifier with its underlying QueryEndpoint and its with relation, which is the keypath to the child property.

    Declaration

    Swift

    public init(_ readEndpoint: R, path: ChildrenPath)

    Parameters

    queryEndpoint

    The QueryEndpoint which the modifer is attached to.

    childrenPath

    A KeyPath which leads to the child property.

  • Builds a query on the queryEndpoint‘s query by attaching a with query modifier.

    Throws

    An Abort error if the item is not found.

    Declaration

    Swift

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

    Parameters

    req

    An incoming Request.

    Return Value

    A QueryBuilder, which represents a Fluent query after having attached a with modifier to the queryEndpoint‘s query.

  • A method which eager loads objects related to the QuerySubject as defined by the KeyPath.

    Throws

    An Abort error if the item is not found.

    Declaration

    Swift

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

    Parameters

    req

    An incoming Request.

    Return Value

    An EventLoopFuture containing an eagerloaded value as defined by Element.