CoreStore querying utilities

This commit is contained in:
John Rommel Estropia
2017-09-20 00:24:03 +09:00
parent 3d427c29c4
commit e45d67252c
2 changed files with 43 additions and 1 deletions

View File

@@ -99,6 +99,12 @@ public extension CoreStore {
return self.defaultStack.fetchOne(from, fetchClauses)
}
// TODO: docs
public static func fetchOne<B: FetchChainableBuilderType>(_ clauseChain: B) -> B.ObjectType? {
return self.defaultStack.fetchOne(clauseChain)
}
/**
Using the `defaultStack`, fetches all `DynamicObject` instances that satisfy the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
@@ -123,6 +129,12 @@ public extension CoreStore {
return self.defaultStack.fetchAll(from, fetchClauses)
}
// TODO: docs
public static func fetchAll<B: FetchChainableBuilderType>(_ clauseChain: B) -> [B.ObjectType]? {
return self.defaultStack.fetchAll(clauseChain)
}
/**
Using the `defaultStack`, fetches the number of `DynamicObject`s that satisfy the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
@@ -147,6 +159,12 @@ public extension CoreStore {
return self.defaultStack.fetchCount(from, fetchClauses)
}
// TODO: docs
public static func fetchCount<B: FetchChainableBuilderType>(_ clauseChain: B) -> Int? {
return self.defaultStack.fetchCount(clauseChain)
}
/**
Using the `defaultStack`, fetches the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
@@ -171,6 +189,12 @@ public extension CoreStore {
return self.defaultStack.fetchObjectID(from, fetchClauses)
}
// TODO: docs
public static func fetchObjectID<B: FetchChainableBuilderType>(_ clauseChain: B) -> NSManagedObjectID? {
return self.defaultStack.fetchObjectID(clauseChain)
}
/**
Using the `defaultStack`, fetches the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
@@ -195,6 +219,12 @@ public extension CoreStore {
return self.defaultStack.fetchObjectIDs(from, fetchClauses)
}
// TODO: docs
public static func fetchObjectIDs<B: FetchChainableBuilderType>(_ clauseChain: B) -> [NSManagedObjectID]? {
return self.defaultStack.fetchObjectIDs(clauseChain)
}
/**
Using the `defaultStack`, queries aggregate values as specified by the `QueryClause`s. Requires at least a `Select` clause, and optional `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
@@ -225,6 +255,12 @@ public extension CoreStore {
return self.defaultStack.queryValue(from, selectClause, queryClauses)
}
// TODO: docs
public static func queryValue<B: QueryChainableBuilderType>(_ clauseChain: B) -> B.ResultType? where B.ResultType: QueryableAttributeType {
return self.defaultStack.queryValue(clauseChain)
}
/**
Using the `defaultStack`, queries a dictionary of attribtue values as specified by the `QueryClause`s. Requires at least a `Select` clause, and optional `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
@@ -254,4 +290,10 @@ public extension CoreStore {
return self.defaultStack.queryAttributes(from, selectClause, queryClauses)
}
// TODO: docs
public static func queryAttributes<B: QueryChainableBuilderType>(_ clauseChain: B) -> [[String: Any]]? where B.ResultType == NSDictionary {
return self.defaultStack.queryAttributes(clauseChain)
}
}

View File

@@ -477,7 +477,7 @@ CSSelect *_Nonnull CSSelectData(CSSelectTerm *_Nonnull selectTerm) CORESTORE_RET
a <tt>CSSelect</tt> clause for querying an <tt>NSManagedObjectID</tt> value
*/
CORESTORE_EXTERN
CSSelect *_Nonnull CSSelectObjectID() CORESTORE_RETURNS_RETAINED;
CSSelect *_Nonnull CSSelectObjectID(void) CORESTORE_RETURNS_RETAINED;
#pragma mark CSTweak