Skip to content

Commit

Permalink
Fix Table.createLocalOnly and AttachmentTable constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
Manrich121 committed Nov 1, 2023
1 parent e77c573 commit 2032643
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 20 deletions.
5 changes: 5 additions & 0 deletions .changeset/brown-insects-tell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@journeyapps/powersync-sdk-common': patch
---

Fix `Table.createLocalOnly` to not also be `insertOnly`
4 changes: 3 additions & 1 deletion packages/powersync-attachments/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# @journeyapps/powersync-attachments

## 0.0.1
## 0.0.1

Initial release.
32 changes: 14 additions & 18 deletions packages/powersync-attachments/src/Schema.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import {
Column,
ColumnType,
Table,
TableOptions,
} from "@journeyapps/powersync-sdk-common";
import { Column, ColumnType, Table, TableOptions } from '@journeyapps/powersync-sdk-common';

export const ATTACHMENT_TABLE = "attachments";
export const ATTACHMENT_TABLE = 'attachments';

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

export interface AttachmentTableOptions
extends Omit<TableOptions, "name" | "columns"> {
export interface AttachmentTableOptions extends Omit<TableOptions, 'name' | 'columns'> {
name?: string;
additionalColumns?: Column[];
}
Expand All @@ -36,15 +30,17 @@ export class AttachmentTable extends Table {
super({
...options,
name: options?.name ?? ATTACHMENT_TABLE,
localOnly: true,
insertOnly: false,
columns: [
new Column({ name: "filename", type: ColumnType.TEXT }),
new Column({ name: "local_uri", type: ColumnType.TEXT }),
new Column({ name: "timestamp", type: ColumnType.INTEGER }),
new Column({ name: "size", type: ColumnType.INTEGER }),
new Column({ name: "media_type", type: ColumnType.TEXT }),
new Column({ name: "state", type: ColumnType.INTEGER }), // Corresponds to AttachmentState
...(options?.additionalColumns ?? []),
],
new Column({ name: 'filename', type: ColumnType.TEXT }),
new Column({ name: 'local_uri', type: ColumnType.TEXT }),
new Column({ name: 'timestamp', type: ColumnType.INTEGER }),
new Column({ name: 'size', type: ColumnType.INTEGER }),
new Column({ name: 'media_type', type: ColumnType.TEXT }),
new Column({ name: 'state', type: ColumnType.INTEGER }), // Corresponds to AttachmentState
...(options?.additionalColumns ?? [])
]
});
}
}
2 changes: 1 addition & 1 deletion packages/powersync-sdk-common/src/db/schema/Table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class Table {
protected options: TableOptions;

static createLocalOnly(options: TableOptions) {
return new Table({ ...options, localOnly: true, insertOnly: true });
return new Table({ ...options, localOnly: true, insertOnly: false });
}

static createInsertOnly(options: TableOptions) {
Expand Down

0 comments on commit 2032643

Please sign in to comment.