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 all KeyPaths 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 strategy URL creation method takes precedence over the FilterStrategy that is specified over the Service.

    Declaration

    Swift

    case server(Filter<K, V>, _: ((String, String, String) -> URLQueryItem)? = nil)
  • specifies that the filter process is realized through the REST property wrapper locally by the client.

    Declaration

    Swift

    case client(Filter<K, V>)
  • specfies that filtering is not wanted and the default case.

    Declaration

    Swift

    case none

Filter

  • represents a filter that takes a generic RESTElement and Filterable element to perform the operations: greater equal, less equal and exists, with the possibility to have more than one filter operation

    See more

    Declaration

    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