keyPath utilities for SectionBy clauses

This commit is contained in:
John Rommel Estropia
2017-09-24 10:38:17 +09:00
parent e814733ae9
commit 645034dde5
12 changed files with 207 additions and 58 deletions

View File

@@ -51,7 +51,7 @@ public protocol SectionMonitorBuilderType {
associatedtype ObjectType: DynamicObject
var from: From<ObjectType> { get set }
var sectionBy: SectionBy { get set }
var sectionBy: SectionBy<ObjectType> { get set }
var fetchClauses: [FetchClause] { get set }
}
@@ -92,7 +92,7 @@ public struct SectionMonitorChainBuilder<D: DynamicObject>: SectionMonitorBuilde
// MARK: SectionMonitorBuilderType
public var from: From<D>
public var sectionBy: SectionBy
public var sectionBy: SectionBy<D>
public var fetchClauses: [FetchClause] = []
}
@@ -101,6 +101,15 @@ public struct SectionMonitorChainBuilder<D: DynamicObject>: SectionMonitorBuilde
public extension From {
public func select<R>(_ clause: Select<D, R>) -> QueryChainBuilder<D, R> {
return .init(
from: self,
select: clause,
queryClauses: []
)
}
public func select<R>(_ resultType: R.Type, _ selectTerm: SelectTerm<D>, _ selectTerms: SelectTerm<D>...) -> QueryChainBuilder<D, R> {
return self.select(resultType, [selectTerm] + selectTerms)
@@ -115,6 +124,16 @@ public extension From {
)
}
@available(OSX 10.12, *)
public func sectionBy(_ clause: SectionBy<D>) -> SectionMonitorChainBuilder<D> {
return .init(
from: self,
sectionBy: clause,
fetchClauses: []
)
}
@available(OSX 10.12, *)
public func sectionBy(_ sectionKeyPath: KeyPathString) -> SectionMonitorChainBuilder<D> {