Skip to content

Commit 9203ddc

Browse files
committed
A couple quick changes
- Got rid of from method in the Query type. Useless. Just use the constructor. - More work on the README
1 parent 4a81af9 commit 9203ddc

File tree

3 files changed

+4
-8
lines changed

3 files changed

+4
-8
lines changed

CoreDataQueryInterface/Query.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ public struct Query<M: NSManagedObject, R: NSFetchRequestResult> where M: Entity
1616
self.builder = builder
1717
}
1818

19-
public static func from(_: M.Type) -> Query<M, M> {
20-
return Query<M, M>()
21-
}
22-
2319
public func context(managedObjectContext: NSManagedObjectContext) -> Query<M, R> {
2420
var builder = self.builder
2521
builder.managedObjectContext = managedObjectContext

CoreDataQueryInterfaceTests/ManagedObjectContextTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import CoreData
2929
class ManagedObjectContextTests: BaseTestCase {
3030

3131
func testCountWithMOC() {
32-
let departmentCount = try! Query<Department, Department>.from(Department.self).count(managedObjectContext: managedObjectContext)
32+
let departmentCount = try! Query<Department, Department>().count(managedObjectContext: managedObjectContext)
3333
XCTAssertEqual(departmentCount, 3)
3434
}
3535

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,10 @@ Now we can say `$0.weekday == Weekday.Monday`. Any type can be made to participa
109109

110110
### Query Reuse
111111

112-
CDQI uses value types wherever possible. Most CDQI methods such as `filter`, `order`, and so on return value types such as `EntityQuery` or `ExpressionQuery`. This allows techniques such as the following:
112+
CDQI uses value types wherever possible. Most CDQI methods such as `filter`, `order`, and so on return the value type `Query<M, R>`. This allows techniques such as the following:
113113

114114
```swift
115-
let projectQuery = Query<Project, Project>.from(Project.self)
115+
let projectQuery = Query<Project, Project>()
116116
let swiftProjectQuery = projectQuery.filter{ any($0.languages.name == "Swift") }
117117
```
118118

@@ -144,7 +144,7 @@ var swiftProjectNames: [String] = managedObjectContext.from(Project.self).
144144
order(project.name).array(project.name)
145145

146146
// Or we can build it up in multiple lines
147-
var projectQuery = managedObjectContext.from(Project)
147+
var projectQuery = managedObjectContext.from(Project.self)
148148
projectQuery = projectQuery.filter(any(project.languages.name == "Swift"))
149149
projectQuery = projectQuery.order(project.name)
150150
swiftProjectNames = projectQuery.array(project.name)

0 commit comments

Comments
 (0)