Skip to content

Commit 2032643

Browse files
committed
Fix Table.createLocalOnly and AttachmentTable constructor
1 parent e77c573 commit 2032643

File tree

4 files changed

+23
-20
lines changed

4 files changed

+23
-20
lines changed

.changeset/brown-insects-tell.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@journeyapps/powersync-sdk-common': patch
3+
---
4+
5+
Fix `Table.createLocalOnly` to not also be `insertOnly`
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
# @journeyapps/powersync-attachments
22

3-
## 0.0.1
3+
## 0.0.1
4+
5+
Initial release.
Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
import {
2-
Column,
3-
ColumnType,
4-
Table,
5-
TableOptions,
6-
} from "@journeyapps/powersync-sdk-common";
1+
import { Column, ColumnType, Table, TableOptions } from '@journeyapps/powersync-sdk-common';
72

8-
export const ATTACHMENT_TABLE = "attachments";
3+
export const ATTACHMENT_TABLE = 'attachments';
94

105
export interface AttachmentRecord {
116
id: string;
@@ -22,11 +17,10 @@ export enum AttachmentState {
2217
QUEUED_UPLOAD = 1, // Attachment to be uploaded
2318
QUEUED_DOWNLOAD = 2, // Attachment to be downloaded
2419
SYNCED = 3, // Attachment has been synced
25-
ARCHIVED = 4, // Attachment has been orphaned, i.e. the associated record has been deleted
20+
ARCHIVED = 4 // Attachment has been orphaned, i.e. the associated record has been deleted
2621
}
2722

28-
export interface AttachmentTableOptions
29-
extends Omit<TableOptions, "name" | "columns"> {
23+
export interface AttachmentTableOptions extends Omit<TableOptions, 'name' | 'columns'> {
3024
name?: string;
3125
additionalColumns?: Column[];
3226
}
@@ -36,15 +30,17 @@ export class AttachmentTable extends Table {
3630
super({
3731
...options,
3832
name: options?.name ?? ATTACHMENT_TABLE,
33+
localOnly: true,
34+
insertOnly: false,
3935
columns: [
40-
new Column({ name: "filename", type: ColumnType.TEXT }),
41-
new Column({ name: "local_uri", type: ColumnType.TEXT }),
42-
new Column({ name: "timestamp", type: ColumnType.INTEGER }),
43-
new Column({ name: "size", type: ColumnType.INTEGER }),
44-
new Column({ name: "media_type", type: ColumnType.TEXT }),
45-
new Column({ name: "state", type: ColumnType.INTEGER }), // Corresponds to AttachmentState
46-
...(options?.additionalColumns ?? []),
47-
],
36+
new Column({ name: 'filename', type: ColumnType.TEXT }),
37+
new Column({ name: 'local_uri', type: ColumnType.TEXT }),
38+
new Column({ name: 'timestamp', type: ColumnType.INTEGER }),
39+
new Column({ name: 'size', type: ColumnType.INTEGER }),
40+
new Column({ name: 'media_type', type: ColumnType.TEXT }),
41+
new Column({ name: 'state', type: ColumnType.INTEGER }), // Corresponds to AttachmentState
42+
...(options?.additionalColumns ?? [])
43+
]
4844
});
4945
}
5046
}

packages/powersync-sdk-common/src/db/schema/Table.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class Table {
1919
protected options: TableOptions;
2020

2121
static createLocalOnly(options: TableOptions) {
22-
return new Table({ ...options, localOnly: true, insertOnly: true });
22+
return new Table({ ...options, localOnly: true, insertOnly: false });
2323
}
2424

2525
static createInsertOnly(options: TableOptions) {

0 commit comments

Comments
 (0)