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
105export 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}
0 commit comments