FilterModifier
public final class FilterModifier<
R: ReadEndpoint
>: ReadEndpoint
A class that wraps a component which utilizes a .filter() modifier. That
allows Corvus to chain modifiers, as it gets treated as any other struct
conforming to ReadEndpoint.
-
The return value of the
.query(), so the type being operated on in the current component.Declaration
Swift
public typealias QuerySubject = R.QuerySubject -
The return type for the
.handler()modifier.Declaration
Swift
public typealias Element = [QuerySubject] -
The filter passed to the
.filter()modifier. It is an alias forFluent'sModelValueFilter.Declaration
Swift
public typealias Filter = ModelValueFilter<QuerySubject> -
The filter of the modifier.
Declaration
Swift
public let filter: Filter -
Initializes the modifier with its underlying
QueryEndpointand itsfilter.Declaration
Swift
public init(_ readEndpoint: R, filter: ModelValueFilter<QuerySubject>)Parameters
queryEndpointThe
QueryEndpointwhich the modifer is attached to.filterA Fluent
ModelValueFilterwhich represents a database query to filter values by. -
Builds a query on the
queryEndpoint‘s query by attaching a filter.Throws
AnAborterror if the item is not found.Declaration
Swift
public func query(_ req: Request) throws -> QueryBuilder<QuerySubject>Parameters
reqAn incoming
Request.Return Value
A
QueryBuilder, which represents aFluentquery after having attached a filter to thequeryEndpoint‘s query. -
A method to return objects found in the
.query()from the database.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 array of theFilterModifier‘sQuerySubject.
FilterModifier Class Reference