mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-03-19 07:54:26 +01:00
complete query utilities
This commit is contained in:
@@ -32,12 +32,7 @@ import CoreData
|
||||
/**
|
||||
The `GroupBy` clause specifies that the result of a query be grouped accoording to the specified key path.
|
||||
*/
|
||||
public struct GroupBy: QueryClause, Hashable {
|
||||
|
||||
/**
|
||||
The list of key path strings to group results with
|
||||
*/
|
||||
public let keyPaths: [KeyPathString]
|
||||
public struct GroupBy<D: DynamicObject>: GroupByClause, QueryClause, Hashable {
|
||||
|
||||
/**
|
||||
Initializes a `GroupBy` clause with an empty list of key path strings
|
||||
@@ -69,6 +64,13 @@ public struct GroupBy: QueryClause, Hashable {
|
||||
}
|
||||
|
||||
|
||||
// MARK: WhereClause
|
||||
|
||||
public typealias ObjectType = D
|
||||
|
||||
public let keyPaths: [KeyPathString]
|
||||
|
||||
|
||||
// MARK: QueryClause
|
||||
|
||||
public func applyToFetchRequest<ResultType>(_ fetchRequest: NSFetchRequest<ResultType>) {
|
||||
@@ -100,3 +102,22 @@ public struct GroupBy: QueryClause, Hashable {
|
||||
return (self.keyPaths as NSArray).hashValue
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - GroupByClause
|
||||
|
||||
/**
|
||||
Abstracts the `GroupBy` clause for protocol utilities.
|
||||
*/
|
||||
public protocol GroupByClause {
|
||||
|
||||
/**
|
||||
The `DynamicObject` type associated with the clause
|
||||
*/
|
||||
associatedtype ObjectType: DynamicObject
|
||||
|
||||
/**
|
||||
The list of key path strings to group results with
|
||||
*/
|
||||
var keyPaths: [KeyPathString] { get }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user