From 627a5d4355e3674b7002c3dbb023d2371cdfc47e Mon Sep 17 00:00:00 2001 From: John Estropia Date: Wed, 19 Feb 2020 22:01:46 +0900 Subject: [PATCH] add OrderBy utilities for Field.Stored --- Sources/OrderBy.swift | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Sources/OrderBy.swift b/Sources/OrderBy.swift index 126f4ae..9e4dd5c 100644 --- a/Sources/OrderBy.swift +++ b/Sources/OrderBy.swift @@ -185,6 +185,14 @@ public struct OrderBy: OrderByClause, FetchClause, QueryClause // MARK: CoreStoreObject Key Paths + + /** + Indicates that the `KeyPathString` should be sorted in ascending order + */ + public static func ascending(_ attribute: KeyPath.Stored>) -> 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: OrderByClause, FetchClause, QueryClause return .ascending(O.meta[keyPath: attribute].keyPath) } + + /** + Indicates that the `KeyPathString` should be sorted in descending order + */ + public static func descending(_ attribute: KeyPath.Stored>) -> SortKey { + + return .descending(O.meta[keyPath: attribute].keyPath) + } /** Indicates that the `KeyPathString` should be sorted in descending order