add OrderBy utilities for Field.Stored

This commit is contained in:
John Estropia
2020-02-19 22:01:46 +09:00
parent 58629bc1df
commit 627a5d4355

View File

@@ -185,6 +185,14 @@ public struct OrderBy<O: DynamicObject>: OrderByClause, FetchClause, QueryClause
// MARK: CoreStoreObject Key Paths
/**
Indicates that the `KeyPathString` should be sorted in ascending order
*/
public static func ascending<T>(_ attribute: KeyPath<O, FieldContainer<O>.Stored<T>>) -> SortKey {
return .ascending(O.meta[keyPath: attribute].keyPath)
}
/**
Indicates that the `KeyPathString` should be sorted in ascending order
@@ -217,6 +225,14 @@ public struct OrderBy<O: DynamicObject>: OrderByClause, FetchClause, QueryClause
return .ascending(O.meta[keyPath: attribute].keyPath)
}
/**
Indicates that the `KeyPathString` should be sorted in descending order
*/
public static func descending<T>(_ attribute: KeyPath<O, FieldContainer<O>.Stored<T>>) -> SortKey {
return .descending(O.meta[keyPath: attribute].keyPath)
}
/**
Indicates that the `KeyPathString` should be sorted in descending order