Skip to content

Commit 2e853d6

Browse files
authored
Fix some old docs. (#65)
1 parent af01e23 commit 2e853d6

File tree

2 files changed

+15
-19
lines changed

2 files changed

+15
-19
lines changed

Sources/SharingGRDBCore/Documentation.docc/Articles/DynamicQueries.md

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ view's body is computed, but could also be more.
4545

4646
This kind of data processing is exactly what SQLite excels at, and so we can offload this work by
4747
modifying the query itself. One can do this with SharingGRDB by using the `load` method on
48-
`SharedReader` in order to load a new key, and hence execute a new query:
48+
``FetchAll``, ``FetchOne`` or ``Fetch`` in order to load a new key, and hence execute a new query:
4949

5050
```swift
5151
struct ContentView: View {
52-
@State.SharedReader(value: []) var items: [Item]
52+
@FetchAll var items: [Item]
5353
@State var filterDate: Date?
5454
@State var order: SortOrder = .reverse
5555

@@ -65,18 +65,16 @@ struct ContentView: View {
6565
private func updateQuery() async {
6666
do {
6767
try await $items.load(
68-
.fetchAll(
69-
Items
70-
.where { $0.timestamp > #bind(filterDate ?? .distantPast) }
71-
.order {
72-
if order == .forward {
73-
$0.timestamp
74-
} else {
75-
$0.timestamp.desc()
76-
}
68+
Items
69+
.where { $0.timestamp > #bind(filterDate ?? .distantPast) }
70+
.order {
71+
if order == .forward {
72+
$0.timestamp
73+
} else {
74+
$0.timestamp.desc()
7775
}
78-
.limit(10)
79-
)
76+
}
77+
.limit(10)
8078
)
8179
} catch {
8280
// Handle error...
@@ -91,6 +89,3 @@ struct ContentView: View {
9189
> initial `@FetchAll`'s value, taken from the parent. To manage the state of this dynamic query
9290
> locally to this view, we use `@State @FetchAll`, instead, and to access the underlying
9391
> `FetchAll` value you can use `wrappedValue`.
94-
95-
> Note: We are using the ``Sharing/SharedReaderKey/fetchAll(_:database:)`` style of
96-
> querying the database. See <doc:Fetching> for more APIs that can be used.

Sources/SharingGRDBCore/Documentation.docc/Articles/Observing.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ macro from SwiftData.
1010

1111
### SwiftUI
1212

13-
The `@FetchAll`, `@FetchOne`, and `@Fetch` property wrappers work in SwiftUI views similarly to how
14-
the `@Query` macro does from SwiftData. You simply add a property to the view that is annotated with
15-
one of the various ways of [querying your database](<doc:Fetching>):
13+
The [`@FetchAll`](<doc:FetchAll>), [`@FetchOne`](<doc:FetchOne>), and [`@Fetch`](<doc:Fetch>)
14+
property wrappers work in SwiftUI views similarly to how the `@Query` macro does from SwiftData.
15+
You simply add a property to the view that is annotated with one of the various ways of
16+
[querying your database](<doc:Fetching>):
1617

1718
```swift
1819
struct ItemsView: View {

0 commit comments

Comments
 (0)