QueryChainBuilder

public struct QueryChainBuilder<O, R> : QueryChainableBuilderType where O : DynamicObject, R : SelectResultType

The fetch builder type used for a queries. A QueryChainBuilder is created from a From clause and then a select(...) chain.

let averageAdultAge = dataStack.queryValue(
    From<MyPersonEntity>()
        .select(Int.self, .average(\.age))
        .where(\.age > 18)
)

QueryChainableBuilderType

QueryChainBuilder

  • Adds a Where clause to the QueryChainBuilder

    Declaration

    Swift

    public func `where`(_ clause: Where<O>) -> QueryChainBuilder<O, R>

    Parameters

    clause

    a Where clause to add to the query builder

    Return Value

    a new QueryChainBuilder containing the Where clause

  • Creates a FetchChainBuilder that ANDs the specified Where clauses. Use this overload if the compiler cannot infer the types when chaining multiple && operators.

    Declaration

    Swift

    public func `where`(combineByAnd clauses: Where<O>...) -> QueryChainBuilder<O, R>

    Parameters

    clauses

    the Where clauses to create a FetchChainBuilder with

    Return Value

    a FetchChainBuilder that ANDs the specified Where clauses

  • Creates a FetchChainBuilder that ORs the specified Where clauses. Use this overload if the compiler cannot infer the types when chaining multiple || operators.

    Declaration

    Swift

    public func `where`(combineByOr clauses: Where<O>...) -> QueryChainBuilder<O, R>

    Parameters

    clauses

    the Where clauses to create a FetchChainBuilder with

    Return Value

    a FetchChainBuilder that ORs the specified Where clauses

  • Adds a Where clause to the QueryChainBuilder

    Declaration

    Swift

    public func `where`(format: String, _ args: Any...) -> QueryChainBuilder<O, R>

    Parameters

    format

    the format string for the predicate

    args

    the arguments for format

    Return Value

    a new QueryChainBuilder containing the Where clause

  • Adds a Where clause to the QueryChainBuilder

    Declaration

    Swift

    public func `where`(format: String, argumentArray: [Any]?) -> QueryChainBuilder<O, R>

    Parameters

    format

    the format string for the predicate

    argumentArray

    the arguments for format

    Return Value

    a new QueryChainBuilder containing the Where clause

  • Adds an OrderBy clause to the QueryChainBuilder

    Declaration

    Swift

    public func orderBy(_ clause: OrderBy<O>) -> QueryChainBuilder<O, R>

    Parameters

    clause

    the OrderBy clause to add

    Return Value

    a new QueryChainBuilder containing the OrderBy clause

  • Adds an OrderBy clause to the QueryChainBuilder

    Declaration

    Swift

    public func orderBy(_ sortKey: OrderBy<O>.SortKey, _ sortKeys: OrderBy<O>.SortKey...) -> QueryChainBuilder<O, R>

    Parameters

    sortKey

    a single SortKey

    sortKeys

    a series of other SortKeys

    Return Value

    a new QueryChainBuilder containing the OrderBy clause

  • Adds an OrderBy clause to the QueryChainBuild

    Declaration

    Swift

    public func orderBy(_ sortKeys: [OrderBy<O>.SortKey]) -> QueryChainBuilder<O, R>

    Parameters

    sortKeys

    a series of SortKeys

    Return Value

    a new QueryChainBuilder containing the OrderBy clause

  • Adds a Tweak clause to the QueryChainBuilder with a closure where the NSFetchRequest may be configured

    Declaration

    Swift

    public func tweak(_ fetchRequest: @escaping (NSFetchRequest<NSFetchRequestResult>) -> Void) -> QueryChainBuilder<O, R>

    Parameters

    fetchRequest

    the block to customize the NSFetchRequest

    Return Value

    a new QueryChainBuilder containing the Tweak clause

  • Adds a GroupBy clause to the QueryChainBuilder

    Declaration

    Swift

    public func groupBy(_ clause: GroupBy<O>) -> QueryChainBuilder<O, R>

    Parameters

    clause

    a GroupBy clause to add to the query builder

    Return Value

    a new QueryChainBuilder containing the GroupBy clause

  • Adds a GroupBy clause to the QueryChainBuilder

    Declaration

    Swift

    public func groupBy(_ keyPath: KeyPathString, _ keyPaths: KeyPathString...) -> QueryChainBuilder<O, R>

    Parameters

    keyPath

    a key path to group the query results with

    keyPaths

    other key paths to group the query results with

    Return Value

    a new QueryChainBuilder containing the GroupBy clause

  • Adds a GroupBy clause to the QueryChainBuilder

    Declaration

    Swift

    public func groupBy(_ keyPaths: [KeyPathString]) -> QueryChainBuilder<O, R>

    Parameters

    keyPaths

    a series of key paths to group the query results with

    Return Value

    a new QueryChainBuilder containing the GroupBy clause

  • Appends a QueryClause to the QueryChainBuilder

    Declaration

    Swift

    public func appending(_ clause: QueryClause) -> QueryChainBuilder<O, R>

    Parameters

    clause

    the QueryClause to add to the QueryChainBuilder

    Return Value

    a new QueryChainBuilder containing the QueryClause

  • Appends a series of QueryClauses to the QueryChainBuilder

    Declaration

    Swift

    public func appending<S>(contentsOf clauses: S) -> QueryChainBuilder<O, R> where S : Sequence, S.Element == QueryClause

    Parameters

    clauses

    the QueryClauses to add to the QueryChainBuilder

    Return Value

    a new QueryChainBuilder containing the QueryClauses

Available where O: NSManagedObject

  • Adds a GroupBy clause to the QueryChainBuilder

    Declaration

    Swift

    public func groupBy<T>(_ keyPath: KeyPath<O, T>) -> QueryChainBuilder<O, R>

    Parameters

    keyPath

    a key path to group the query results with

    Return Value

    a new QueryChainBuilder containing the GroupBy clause

Available where O: CoreStoreObject

  • Adds a Where clause to the QueryChainBuilder

    Declaration

    Swift

    public func `where`<T>(_ clause: (O) -> T) -> QueryChainBuilder<O, R> where T : AnyWhereClause

    Parameters

    clause

    a Where clause to add to the query builder

    Return Value

    a new QueryChainBuilder containing the Where clause

  • Adds a GroupBy clause to the QueryChainBuilder

    Declaration

    Swift

    public func groupBy<T>(_ keyPath: KeyPath<O, FieldContainer<O>.Stored<T>>) -> QueryChainBuilder<O, R> where T : FieldStorableType

    Parameters

    keyPath

    a key path to group the query results with

    Return Value

    a new QueryChainBuilder containing the GroupBy clause

  • Adds a GroupBy clause to the QueryChainBuilder

    Declaration

    Swift

    public func groupBy<T>(_ keyPath: KeyPath<O, FieldContainer<O>.Virtual<T>>) -> QueryChainBuilder<O, R>

    Parameters

    keyPath

    a key path to group the query results with

    Return Value

    a new QueryChainBuilder containing the GroupBy clause

  • Adds a GroupBy clause to the QueryChainBuilder

    Declaration

    Swift

    public func groupBy<T>(_ keyPath: KeyPath<O, FieldContainer<O>.Coded<T>>) -> QueryChainBuilder<O, R>

    Parameters

    keyPath

    a key path to group the query results with

    Return Value

    a new QueryChainBuilder containing the GroupBy clause

  • Adds a GroupBy clause to the QueryChainBuilder

    Declaration

    Swift

    public func groupBy<T>(_ keyPath: KeyPath<O, ValueContainer<O>.Required<T>>) -> QueryChainBuilder<O, R> where T : ImportableAttributeType

    Parameters

    keyPath

    a key path to group the query results with

    Return Value

    a new QueryChainBuilder containing the GroupBy clause

  • Adds a GroupBy clause to the QueryChainBuilder

    Declaration

    Swift

    public func groupBy<T>(_ keyPath: KeyPath<O, ValueContainer<O>.Optional<T>>) -> QueryChainBuilder<O, R> where T : ImportableAttributeType

    Parameters

    keyPath

    a key path to group the query results with

    Return Value

    a new QueryChainBuilder containing the GroupBy clause

  • Adds a GroupBy clause to the QueryChainBuilder

    Declaration

    Swift

    public func groupBy<T>(_ keyPath: KeyPath<O, TransformableContainer<O>.Required<T>>) -> QueryChainBuilder<O, R> where T : NSCoding, T : NSCopying

    Parameters

    keyPath

    a key path to group the query results with

    Return Value

    a new QueryChainBuilder containing the GroupBy clause

  • Adds a GroupBy clause to the QueryChainBuilder

    Declaration

    Swift

    public func groupBy<T>(_ keyPath: KeyPath<O, TransformableContainer<O>.Optional<T>>) -> QueryChainBuilder<O, R> where T : NSCoding, T : NSCopying

    Parameters

    keyPath

    a key path to group the query results with

    Return Value

    a new QueryChainBuilder containing the GroupBy clause