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's
ModelValueFilter
.Declaration
Swift
public typealias Filter = ModelValueFilter<QuerySubject>
-
The filter of the modifier.
Declaration
Swift
public let filter: Filter
-
Initializes the modifier with its underlying
QueryEndpoint
and itsfilter
.Declaration
Swift
public init(_ readEndpoint: R, filter: ModelValueFilter<QuerySubject>)
Parameters
queryEndpoint
The
QueryEndpoint
which the modifer is attached to.filter
A Fluent
ModelValueFilter
which represents a database query to filter values by. -
Builds a query on the
queryEndpoint
‘s query by attaching a filter.Throws
AnAbort
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 aFluent
query after having attached a filter to thequeryEndpoint
‘s query. -
A method to return objects found in the
.query()
from the database.Throws
AnAbort
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 array of theFilterModifier
‘sQuerySubject
.