Skip to content
This repository has been archived by the owner on Feb 28, 2020. It is now read-only.

Commit

Permalink
Added support to last method in Query
Browse files Browse the repository at this point in the history
  • Loading branch information
vmartinelli committed Jun 25, 2018
1 parent 3c19bf9 commit 5fcde2a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Source/AlecrimCoreData/Core/Query/FetchRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ public struct FetchRequest<Entity: ManagedObject>: Queryable {
return rawValue
}

internal func reversed() -> FetchRequest<Entity> {
guard let existingSortDescriptors = self.sortDescriptors, !existingSortDescriptors.isEmpty else {
return self
}

var clone = self
clone.sortDescriptors = existingSortDescriptors.map { SortDescriptor(key: $0.key, ascending: !$0.ascending) }

return clone
}

}

// MARK: -
Expand Down

0 comments on commit 5fcde2a

Please sign in to comment.