FilterStrategy
public enum FilterStrategy<K, V> where K : Reflectable, K : Comparable, K : Decodable, K : Encodable, K : Hashable, K : Identifiable, V : Reflectable, V : ReflectionDecodable, V : Comparable, V : CustomStringConvertible, V : Decodable, V : Encodable
represents the filter strategy with the different options client, server and none filter
How to define a FilterStrategy:
FilterStrategy example:
basic structure:
.strategy(FilterStrategy.Filter(operations: operation1, operation2, ...)))
client example:
let clientStrategy = .client(FilterStrategy.Filter(operations: [.lte(\Account.id!, 100), .gte(\Account.id!, )])))
defines a filter strategy where a fictional account class is filtered for 1 <= ID <= 100
Attention
You can only define the operations array where allKeyPaths are from the same data type
-
specifies that the filter process is realized through a server route; the user has the option to specify an own translation function in the case
Important
The configuration of an own server strategyURLcreation method takes precedence over theFilterStrategythat is specified over theService.Declaration
Swift
case server(Filter<K, V>, _: ((String, String, String) -> URLQueryItem)? = nil) -
specfies that filtering is not wanted and the default case.
Declaration
Swift
case none
-
represents a filter that takes a generic
See moreRESTElementandFilterableelement to perform the operations: greater equal, less equal and exists, with the possibility to have more than one filter operationDeclaration
Swift
public class Filter<K, V> where K : Reflectable, K : Comparable, K : Decodable, K : Encodable, K : Hashable, K : Identifiable, V : Reflectable, V : ReflectionDecodable, V : Comparable, V : CustomStringConvertible, V : Decodable, V : Encodable
View on GitHub
FilterStrategy Enumeration Reference