Description
Lightweight Core Data fetch framework. With FetchKit you can easy fetch data from store without creating NSFetchRequest.
FetchKit alternatives and similar libraries
Based on the "Core Data" category.
Alternatively, view FetchKit alternatives based on common mentions on social networks and blogs.
-
PrediKit
An NSPredicate DSL for iOS, OSX, tvOS, & watchOS. Inspired by SnapKit and lovingly written in Swift. -
Skopelos
A minimalistic, thread safe, non-boilerplate and super easy to use version of Active Record on Core Data. Simply all you need for doing Core Data. Swift flavour. -
JustPersist
DISCONTINUED. JustPersist is the easiest and safest way to do persistence on iOS with Core Data support out of the box. It also allows you to migrate to any other persistence framework with minimal effort. -
SLRESTfulCoreData
Objc naming conventions, autogenerated accessors at runtime, URL substitutions and intelligent attribute mapping -
CloudCore
Robust CoreData-CloudKit synchronization, including offline queuing, relationships, private, shared and public databases, field-level deltas, encrypted values, maskable attributes, cacheable assets, and more. -
Cadmium
A Swift framework that wraps CoreData, hides context complexity, and helps facilitate best practices. -
CoreDataDandy
DISCONTINUED. A feature-light wrapper around Core Data that simplifies common database operations.
InfluxDB - Purpose built for real-time analytics at any scale.
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of FetchKit or a related project?
README
FetchKit
Lightweight Core Data fetch framework.
With FetchKit you can easily fetch data from store without creating NSFetchRequest
.
Usage
Example Core Data entity
@objc(User)
class User: NSManagedObject {
@NSManaged var id: Int64
@NSManaged var firstName: String?
@NSManaged var lastName: String?
@NSManaged var salary: Int64
}
extension User: QueryProtocol { }
Find first
Find first User
. Sorted by firstName.
let user = try? User.findFirst()
.sorted(by: \User.firstName)
.execute(in: context)
Find all
Find all Users
with first name John
let allJohns = try? User.findAll()
.where(\User.firstName, equals: "John")
.execute(in: context)
Find range
let ranged = try? User.findRange(2..<5)
.sorted(by: \User.id)
.execute(in: context)
Get count
let usersCount = try? User.getCount()
.execute(in: context)
Min
Aggregate minimimum value of entity property
let minId = try? User.getMin(keyPath: \User.id)
.execute(in: context)
Max
Aggregate maximum value of entity property
let maxId = try? User.getMax(keyPath: \User.id)
.execute(in: context)
Delete
Delete all Users
with first name John and returns count
let deleteCount = try? User.deleteAll()
.where(\User.firstName, equals: "John")
.execute(in: context)
Get Distinct
Fetch dictionaries (instead of managed objects) with specified properties and aggregation functions. Result can be grouped by properties (SQL GROUP BY)
let result = try User.getDistinct()
.propertiesToFetch([\User.firstName])
.aggregate(keyPath: \User.salary, function: "sum:", saveAs: "totalSalary")
.group(by: \User.firstName)
.execute(in: context)
Fetched results controller
Return NSFetchedResultsContoller
and perform fetch
let userFetchedResults = try? User.fetchResults()
.group(by: \User.firstName)
.sorted(by: \User.firstName)
.sorted(by: \User.lastName)
.execute(in: context)
Requirements
- iOS 8.0+ / macOS 10.9+ / tvOS 9.0+ / watchOS 2.0+
- Xcode 11.0+
- Swift 5.1+
Installation
CocoaPods
To integrate FetchKit into your Xcode project using CocoaPods, specify it in your Podfile
:
pod 'FetchKit'
License
FetchKit is released under the BSD license. See [LICENSE](LICENSE).
*Note that all licence references and agreements mentioned in the FetchKit README section above
are relevant to that project's source code only.