Skip to content

Commit a9d1954

Browse files
authored
Fix: Update attachments README (#451)
1 parent 4a262cd commit a9d1954

File tree

1 file changed

+20
-22
lines changed

1 file changed

+20
-22
lines changed

packages/attachments/README.md

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -33,24 +33,20 @@ In this example, the user captures photos when checklist items are completed as
3333
The schema for the `checklist` table:
3434

3535
```javascript
36-
const AppSchema = new Schema([
37-
new Table({
38-
name: 'checklists',
39-
columns: [
40-
new Column({ name: 'photo_id', type: ColumnType.TEXT }),
41-
new Column({ name: 'description', type: ColumnType.TEXT }),
42-
new Column({ name: 'completed', type: ColumnType.INTEGER }),
43-
new Column({ name: 'completed_at', type: ColumnType.TEXT }),
44-
new Column({ name: 'completed_by', type: ColumnType.TEXT })
45-
],
46-
indexes: [
47-
new Index({
48-
name: 'inspections',
49-
columns: [new IndexedColumn({ name: 'checklist_id' })]
50-
})
51-
]
52-
})
53-
]);
36+
const checklists = new Table(
37+
{
38+
photo_id: column.text,
39+
description: column.text,
40+
completed: column.integer,
41+
completed_at: column.text,
42+
completed_by: column.text
43+
},
44+
{ indexes: { inspections: ['checklist_id'] } }
45+
);
46+
47+
const AppSchema = new Schema({
48+
checklists
49+
});
5450
```
5551

5652
### Steps to implement
@@ -107,10 +103,12 @@ export class AttachmentQueue extends AbstractAttachmentQueue {
107103
```javascript
108104
import { AttachmentTable } from '@powersync/attachments';
109105

110-
const AppSchema = new Schema([
106+
const attachmentTable = new AttachmentTable();
107+
108+
const AppSchema = new Schema({
111109
// ... other tables
112-
new AttachmentTable()
113-
]);
110+
attachmentTable
111+
});
114112
```
115113
116114
In addition to `Table` options, the `AttachmentTable` can optionally be configured with the following options:
@@ -132,7 +130,7 @@ The default columns in `AttachmentTable`:
132130
| `size` | `INTEGER` | The size of the attachment in bytes |
133131
134132
5. To instantiate an `AttachmentQueue`, one needs to provide an instance of `AbstractPowerSyncDatabase` from PowerSync and an instance of `StorageAdapter`.
135-
See the `StorageAdapter` interface definition [here](./src/StorageAdapter.ts).
133+
See the `StorageAdapter` interface definition [here](https://github.com/powersync-ja/powersync-js/blob/main/packages/attachments/src/StorageAdapter.ts).
136134
137135
6. Instantiate a new `AttachmentQueue` and call `init()` to start syncing attachments. Our example, uses a `StorageAdapter` that integrates with Supabase Storage.
138136

0 commit comments

Comments
 (0)