Skip to content

Commit 495ce97

Browse files
cleanup
1 parent 22c96e9 commit 495ce97

File tree

1 file changed

+18
-24
lines changed

1 file changed

+18
-24
lines changed

Sources/PowerSync/attachments/README.md

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
A [PowerSync](https://powersync.com) library to manage attachments in Swift apps.
44

5-
This package is included in the PowerSync Core module.
6-
75
## Alpha Release
86

97
Attachment helpers are currently in an alpha state, intended strictly for testing. Expect breaking changes and instability as development continues.
@@ -25,7 +23,7 @@ An `AttachmentQueue` is used to manage and sync attachments in your app. The att
2523

2624
See the [PowerSync Example Demo](../../../Demo/PowerSyncExample) for a basic example of attachment syncing.
2725

28-
In this example, the user captures photos when checklist items are completed as part of an inspection workflow.
26+
In this example below, the user captures photos when checklist items are completed as part of an inspection workflow.
2927

3028
The schema for the `checklist` table:
3129

@@ -47,26 +45,7 @@ let schema = Schema(
4745
)
4846
```
4947

50-
The `createAttachmentTable` function defines the local-only attachment state storage table.
51-
52-
An attachments table definition can be created with the following options:
53-
54-
| Option | Description | Default |
55-
| ------ | --------------------- | ------------- |
56-
| `name` | The name of the table | `attachments` |
57-
58-
The default columns in `AttachmentTable`:
59-
60-
| Column Name | Type | Description |
61-
| ------------ | --------- | ------------------------------------------------------------------------------------------------------------------ |
62-
| `id` | `TEXT` | The ID of the attachment record |
63-
| `filename` | `TEXT` | The filename of the attachment |
64-
| `media_type` | `TEXT` | The media type of the attachment |
65-
| `state` | `INTEGER` | The state of the attachment, one of `AttachmentState` enum values |
66-
| `timestamp` | `INTEGER` | The timestamp of the last update to the attachment record |
67-
| `size` | `INTEGER` | The size of the attachment in bytes |
68-
| `has_synced` | `INTEGER` | Internal tracker which tracks if the attachment has ever been synced. This is used for caching/archiving purposes. |
69-
| `meta_data` | `TEXT` | Any extra meta data for the attachment. JSON is usually a good choice. |
48+
The `createAttachmentTable` function defines the `local-only` attachment state storage table. See the [Implementation Details](#implementation-details) section for more details.
7049

7150
#### Steps to Implement
7251

@@ -153,7 +132,7 @@ try await queue.saveFile(
153132
}
154133
```
155134

156-
#### Handling Errors
135+
#### (Optional) Handling Errors
157136

158137
The attachment queue automatically retries failed sync operations. Retries continue indefinitely until success. A `SyncErrorHandler` can be provided to the `AttachmentQueue` constructor. This handler provides methods invoked on a remote sync exception. The handler can return a Boolean indicating if the attachment sync should be retried or archived.
159138

@@ -183,6 +162,21 @@ let queue = AttachmentQueue(
183162

184163
## Implementation Details
185164

165+
### Attachment Table
166+
167+
The default columns in `AttachmentTable`:
168+
169+
| Column Name | Type | Description |
170+
| ------------ | --------- | ------------------------------------------------------------------------------------------------------------------ |
171+
| `id` | `TEXT` | The ID of the attachment record |
172+
| `filename` | `TEXT` | The filename of the attachment |
173+
| `media_type` | `TEXT` | The media type of the attachment |
174+
| `state` | `INTEGER` | The state of the attachment, one of `AttachmentState` enum values |
175+
| `timestamp` | `INTEGER` | The timestamp of the last update to the attachment record |
176+
| `size` | `INTEGER` | The size of the attachment in bytes |
177+
| `has_synced` | `INTEGER` | Internal tracker which tracks if the attachment has ever been synced. This is used for caching/archiving purposes. |
178+
| `meta_data` | `TEXT` | Any extra meta data for the attachment. JSON is usually a good choice. |
179+
186180
### Attachment State
187181

188182
The `AttachmentQueue` class manages attachments in your app by tracking their state.

0 commit comments

Comments
 (0)