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)
)
-
Declaration
Swift
public typealias ObjectType = O
-
Declaration
Swift
public typealias ResultType = R
-
Declaration
Swift
public var from: From<O>
-
Declaration
Swift
public var select: Select<O, R>
-
Declaration
Swift
public var queryClauses: [QueryClause]
-
Creates a
FetchChainBuilder
thatAND
s the specifiedWhere
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 aFetchChainBuilder
withReturn Value
a
FetchChainBuilder
thatAND
s the specifiedWhere
clauses -
Creates a
FetchChainBuilder
thatOR
s the specifiedWhere
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 aFetchChainBuilder
withReturn Value
a
FetchChainBuilder
thatOR
s the specifiedWhere
clauses -
Adds a
Where
clause to theQueryChainBuilder
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 theWhere
clause -
Adds a
Tweak
clause to theQueryChainBuilder
with a closure where theNSFetchRequest
may be configuredDeclaration
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 theTweak
clause -
Adds a
GroupBy
clause to theQueryChainBuilder
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 theGroupBy
clause -
Adds a
GroupBy
clause to theQueryChainBuilder
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 theGroupBy
clause -
Appends a
QueryClause
to theQueryChainBuilder
Declaration
Swift
public func appending(_ clause: QueryClause) -> QueryChainBuilder<O, R>
Parameters
clause
the
QueryClause
to add to theQueryChainBuilder
Return Value
a new
QueryChainBuilder
containing theQueryClause
-
Appends a series of
QueryClause
s to theQueryChainBuilder
Declaration
Swift
public func appending<S>(contentsOf clauses: S) -> QueryChainBuilder<O, R> where S : Sequence, S.Element == QueryClause
Parameters
clauses
the
QueryClause
s to add to theQueryChainBuilder
Return Value
a new
QueryChainBuilder
containing theQueryClause
s
-
Adds a
Where
clause to theQueryChainBuilder
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 builderReturn Value
a new
QueryChainBuilder
containing theWhere
clause -
Adds a
GroupBy
clause to theQueryChainBuilder
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 theGroupBy
clause -
Adds a
GroupBy
clause to theQueryChainBuilder
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 theGroupBy
clause -
Adds a
GroupBy
clause to theQueryChainBuilder
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 theGroupBy
clause -
Adds a
GroupBy
clause to theQueryChainBuilder
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 theGroupBy
clause -
Adds a
GroupBy
clause to theQueryChainBuilder
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 theGroupBy
clause -
Adds a
GroupBy
clause to theQueryChainBuilder
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 theGroupBy
clause -
Adds a
GroupBy
clause to theQueryChainBuilder
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 theGroupBy
clause