Skip to content

Commit 4a81af9

Browse files
committed
README
1 parent 8ddd11f commit 4a81af9

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

README.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,18 @@ Core Data Query Interface (CDQI) is a type-safe, fluent, intuitive library for w
1111
- [x] Optionally eliminates the use of magic strings so common in Core Data
1212
- [x] Query reuse, i.e., no side-effects from chaining
1313
- [x] Support for iOS 9+, macOS 10.11+, tvOS 9+, and watchOS 2+.
14+
- [x] Swift 3 (for Swift 2.2, use v4.0)
1415

1516
### Overview
1617

1718
In essence, CDQI is a tool that allows the creation (and execution) of fetch requests using a fluent syntax. In most cases, this can reduce many lines of code to a single (but still highly readable) line.
1819

1920
```swift
20-
let swiftDevelopers = managedObjectContext.from(Developer).
21+
let swiftDevelopers = managedObjectContext.from(Developer.self).
2122
filter{ any($0.languages.name == "Swift") }.
22-
order(descending: {$0.lastName}).limit(5).all()
23+
order(ascending: false, {$0.lastName})
24+
.limit(5)
25+
.all()
2326
```
2427

2528
### Integration
@@ -40,7 +43,15 @@ Add the following to your `Podfile`. If it isn't already present, you will have
4043
pod 'CoreDataQueryInterface', '~> 5.0'
4144
```
4245

43-
#### Attribute Proxies
46+
### Changes From Previous Versions
47+
48+
The overall syntax of CDQI is unchanged from previous versions, as the examples in this document show. But there are small changes.
49+
50+
First, `EntityQuery`, `ExpressionQuery` and the like are gone, replaced by a single type `Query<M, R>`. The first generic parameter is the type of managed object model to work with. The second parameter is the result type, which must conform to the `NSFetchResultType` protocol. So instead of saying `EntityQuery.from(Project.self)` we say `Query<Project, NSDictionary>.from(Project.self)`.
51+
52+
The second major difference is the use of prefixes on methods, properties, and type aliases. CDQI extends types like `String`,
53+
54+
### Attribute Proxies
4455

4556
In order to use expressions such as `$0.languages.name` as in the example above, proxy objects must be created. In the `bin` folder at the root of the project is a simple tool called `cdqi` that accomplishes this. Before running this tool, make sure that each `NSManagedObject` is represented by a corresponding class in your Swift project.
4657

@@ -115,7 +126,7 @@ A great number of examples can be found in the unit tests and the "Top Hits" exa
115126
let developerQuery = managedObjectContext.from(Developer.self)
116127
// predicate: languages.@count == 3 AND ANY languages.name == "Rust"
117128
// developersWhoKnowThreeLanguagesIncludingRust is an array of Developer entities
118-
let developersWhoKnowThreeLanguagesIncludingRust = developerQuery.filter{ $0.languages.count == 3 &&
129+
let developersWhoKnowThreeLanguagesIncludingRust = developerQuery.filter{ $0.languages.cdqiCount() == 3 &&
119130
any($0.languages.name == "Rust") }.all()
120131

121132
// predicate: ANY languages.name == "Haskell"

0 commit comments

Comments
 (0)