mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-18 06:57:15 +01:00
orderby utilities
This commit is contained in:
@@ -237,6 +237,7 @@ class DynamicModelTests: BaseTestDataTestCase {
|
||||
_ = transaction.fetchAll(
|
||||
From<Dog>()
|
||||
.where(\.age == 10 && \Animal.species == "Dog")
|
||||
.orderBy(.ascending({ $0.species }))
|
||||
)
|
||||
_ = transaction.fetchAll(
|
||||
From<Dog>(),
|
||||
|
||||
@@ -257,6 +257,73 @@ public struct OrderBy<D: DynamicObject>: OrderByClause, FetchClause, QueryClause
|
||||
}
|
||||
}
|
||||
|
||||
public extension OrderBy where D: CoreStoreObject {
|
||||
|
||||
/**
|
||||
Indicates that the `KeyPathString` should be sorted in ascending order
|
||||
*/
|
||||
public static func ascending<DSub, A, T>(_ attribute: (D) -> A) -> SortKey where A: ValueContainer<DSub>.Required<T> {
|
||||
|
||||
return .ascending(attribute(D.meta).keyPath)
|
||||
}
|
||||
|
||||
/**
|
||||
Indicates that the `KeyPathString` should be sorted in ascending order
|
||||
*/
|
||||
public static func ascending<DSub, A, T>(_ attribute: (D) -> A) -> SortKey where A: ValueContainer<DSub>.Optional<T> {
|
||||
|
||||
return .ascending(attribute(D.meta).keyPath)
|
||||
}
|
||||
|
||||
/**
|
||||
Indicates that the `KeyPathString` should be sorted in ascending order
|
||||
*/
|
||||
public static func ascending<DSub, A, T>(_ attribute: (D) -> A) -> SortKey where A: TransformableContainer<DSub>.Required<T> {
|
||||
|
||||
return .ascending(attribute(D.meta).keyPath)
|
||||
}
|
||||
|
||||
/**
|
||||
Indicates that the `KeyPathString` should be sorted in ascending order
|
||||
*/
|
||||
public static func ascending<DSub, A, T>(_ attribute: (D) -> A) -> SortKey where A: TransformableContainer<DSub>.Optional<T> {
|
||||
|
||||
return .ascending(attribute(D.meta).keyPath)
|
||||
}
|
||||
|
||||
/**
|
||||
Indicates that the `KeyPathString` should be sorted in descending order
|
||||
*/
|
||||
public static func descending<DSub, A, T>(_ attribute: (D) -> A) -> SortKey where A: ValueContainer<DSub>.Required<T> {
|
||||
|
||||
return .descending(attribute(D.meta).keyPath)
|
||||
}
|
||||
|
||||
/**
|
||||
Indicates that the `KeyPathString` should be sorted in descending order
|
||||
*/
|
||||
public static func descending<DSub, A, T>(_ attribute: (D) -> A) -> SortKey where A: ValueContainer<DSub>.Optional<T> {
|
||||
|
||||
return .descending(attribute(D.meta).keyPath)
|
||||
}
|
||||
|
||||
/**
|
||||
Indicates that the `KeyPathString` should be sorted in descending order
|
||||
*/
|
||||
public static func descending<DSub, A, T>(_ attribute: (D) -> A) -> SortKey where A: TransformableContainer<DSub>.Required<T> {
|
||||
|
||||
return .descending(attribute(D.meta).keyPath)
|
||||
}
|
||||
|
||||
/**
|
||||
Indicates that the `KeyPathString` should be sorted in descending order
|
||||
*/
|
||||
public static func descending<DSub, A, T>(_ attribute: (D) -> A) -> SortKey where A: TransformableContainer<DSub>.Optional<T> {
|
||||
|
||||
return .descending(attribute(D.meta).keyPath)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - OrderByClause
|
||||
|
||||
|
||||
Reference in New Issue
Block a user