-
Notifications
You must be signed in to change notification settings - Fork 0
Fetch wrappers plus relationship and property fetching modifiers #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| import CoreData | ||
| import Dependencies | ||
| import SwiftData | ||
| #if canImport(SwiftUI) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't need this anymore
| } | ||
| } | ||
|
|
||
| #if canImport(SwiftUI) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed with Observable
| import CoreData | ||
| import Dependencies | ||
| import SwiftData | ||
| #if canImport(SwiftUI) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
| } | ||
| } | ||
|
|
||
| #if canImport(SwiftUI) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
| /// A range representing the number of results to skip before returning matches and maximum number of results to fetch. When `nil`, the query will return all matching results. | ||
| public var range: Range<Int>? | ||
|
|
||
| public var relationshipKeyPaths: [PartialKeyPath<T>] = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
documentation
Sources/SwiftQuery/Query.swift
Outdated
| /// .prefetchRelationship(\.customer) | ||
| /// .prefetchRelationship(\.items) | ||
| /// ``` | ||
| func prefetchRelationship(_ keyPath: PartialKeyPath<T>) -> Self { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This really should work the way prefetchKeyPaths() does and take a variadic list of keypaths.
Added property wrappers that automatically update when data matching a query changes:
Added prefetchRelationship() to reduce database trips when accessing related objects and support fetch wrappers returning a larger portion of the graph.
Added fetchKeyPaths() to fetch only specific properties, which can improve performance for a given fetch.