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
KeyPathto the related attribute of theQuerySubjectthat is to be loaded.Declaration
Swift
public typealias ChildrenPath = KeyPath< ParentQuerySubject, ParentQuerySubject.Children<M> > -
Initializes the modifier with its underlying
QueryEndpointand itswithrelation, which is the keypath to the child property.Declaration
Swift
public init(_ readEndpoint: R, path: ChildrenPath)Parameters
queryEndpointThe
QueryEndpointwhich the modifer is attached to.childrenPathA
KeyPathwhich leads to the child property. -
Builds a query on the
queryEndpoint‘s query by attaching a with query modifier.Throws
AnAborterror if the item is not found.Declaration
Swift
public func query(_ req: Request) throws -> QueryBuilder<ParentQuerySubject>Parameters
reqAn incoming
Request.Return Value
A
QueryBuilder, which represents aFluentquery after having attached a with modifier to thequeryEndpoint‘s query. -
A method which eager loads objects related to the
QuerySubjectas defined by theKeyPath.Throws
AnAborterror if the item is not found.Declaration
Swift
public func handler(_ req: Request) throws -> EventLoopFuture<Element>Parameters
reqAn incoming
Request.Return Value
An
EventLoopFuturecontaining an eagerloaded value as defined byElement.
ChildrenModifier Class Reference