-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: clean up attachments readme and update demos
- Loading branch information
1 parent
a9d1954
commit 7958755
Showing
5 changed files
with
671 additions
and
209 deletions.
There are no files selected for viewing
82 changes: 32 additions & 50 deletions
82
demos/react-native-supabase-todolist/library/powersync/AppSchema.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,40 @@ | ||
import { AttachmentTable } from '@powersync/attachments'; | ||
import { Column, ColumnType, Index, IndexedColumn, Schema, Table } from '@powersync/react-native'; | ||
import { column, Schema, Table } from '@powersync/react-native'; | ||
|
||
export const TODO_TABLE = 'todos'; | ||
export const LIST_TABLE = 'lists'; | ||
export const TODO_TABLE = 'todos'; | ||
|
||
export interface ListRecord { | ||
id: string; | ||
name: string; | ||
created_at: string; | ||
owner_id?: string; | ||
} | ||
const todos = new Table( | ||
{ | ||
list_id: column.text, | ||
photo_id: column.text, | ||
created_at: column.text, | ||
completed_at: column.text, | ||
description: column.text, | ||
created_by: column.text, | ||
completed_by: column.text, | ||
completed: column.integer | ||
}, | ||
{ indexes: { list: ['list_id'] } } | ||
); | ||
|
||
export interface TodoRecord { | ||
id: string; | ||
created_at: string; | ||
completed: boolean; | ||
description: string; | ||
completed_at?: string; | ||
const lists = new Table({ | ||
created_at: column.text, | ||
name: column.text, | ||
owner_id: column.text | ||
}); | ||
|
||
created_by: string; | ||
completed_by?: string; | ||
list_id: string; | ||
export const AppSchema = new Schema({ | ||
todos, | ||
lists, | ||
attachments: new AttachmentTable({ | ||
name: 'attachments', | ||
}), | ||
}); | ||
|
||
photo_id?: string; // This is the attachment id, 1:1 relationship with `id` in AttachmentTable | ||
} | ||
export type Database = (typeof AppSchema)['types']; | ||
export type TodoRecord = Database['todos']; | ||
// OR: | ||
// export type Todo = RowType<typeof todos>; | ||
|
||
export const AppSchema = new Schema([ | ||
new Table({ | ||
name: 'todos', | ||
columns: [ | ||
new Column({ name: 'list_id', type: ColumnType.TEXT }), | ||
new Column({ name: 'photo_id', type: ColumnType.TEXT }), | ||
new Column({ name: 'created_at', type: ColumnType.TEXT }), | ||
new Column({ name: 'completed_at', type: ColumnType.TEXT }), | ||
new Column({ name: 'description', type: ColumnType.TEXT }), | ||
new Column({ name: 'completed', type: ColumnType.INTEGER }), | ||
new Column({ name: 'created_by', type: ColumnType.TEXT }), | ||
new Column({ name: 'completed_by', type: ColumnType.TEXT }) | ||
], | ||
indexes: [ | ||
new Index({ | ||
name: 'list', | ||
columns: [new IndexedColumn({ name: 'list_id' })] | ||
}) | ||
] | ||
}), | ||
new Table({ | ||
name: 'lists', | ||
columns: [ | ||
new Column({ name: 'created_at', type: ColumnType.TEXT }), | ||
new Column({ name: 'name', type: ColumnType.TEXT }), | ||
new Column({ name: 'owner_id', type: ColumnType.TEXT }) | ||
] | ||
}), | ||
// Add Attachment table | ||
new AttachmentTable() | ||
]); | ||
export type ListRecord = Database['lists']; |
82 changes: 32 additions & 50 deletions
82
demos/react-native-web-supabase-todolist/library/powersync/AppSchema.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,40 @@ | ||
import { AttachmentTable } from '@powersync/attachments'; | ||
import { Column, ColumnType, Index, IndexedColumn, Schema, Table } from '@powersync/common'; | ||
import { column, Schema, Table } from '@powersync/react-native'; | ||
|
||
export const TODO_TABLE = 'todos'; | ||
export const LIST_TABLE = 'lists'; | ||
export const TODO_TABLE = 'todos'; | ||
|
||
export interface ListRecord { | ||
id: string; | ||
name: string; | ||
created_at: string; | ||
owner_id?: string; | ||
} | ||
const todos = new Table( | ||
{ | ||
list_id: column.text, | ||
photo_id: column.text, | ||
created_at: column.text, | ||
completed_at: column.text, | ||
description: column.text, | ||
created_by: column.text, | ||
completed_by: column.text, | ||
completed: column.integer | ||
}, | ||
{ indexes: { list: ['list_id'] } } | ||
); | ||
|
||
export interface TodoRecord { | ||
id: string; | ||
created_at: string; | ||
completed: boolean; | ||
description: string; | ||
completed_at?: string; | ||
const lists = new Table({ | ||
created_at: column.text, | ||
name: column.text, | ||
owner_id: column.text | ||
}); | ||
|
||
created_by: string; | ||
completed_by?: string; | ||
list_id: string; | ||
export const AppSchema = new Schema({ | ||
todos, | ||
lists, | ||
attachments: new AttachmentTable({ | ||
name: 'attachments', | ||
}), | ||
}); | ||
|
||
photo_id?: string; // This is the attachment id, 1:1 relationship with `id` in AttachmentTable | ||
} | ||
export type Database = (typeof AppSchema)['types']; | ||
export type TodoRecord = Database['todos']; | ||
// OR: | ||
// export type Todo = RowType<typeof todos>; | ||
|
||
export const AppSchema = new Schema([ | ||
new Table({ | ||
name: 'todos', | ||
columns: [ | ||
new Column({ name: 'list_id', type: ColumnType.TEXT }), | ||
new Column({ name: 'photo_id', type: ColumnType.TEXT }), | ||
new Column({ name: 'created_at', type: ColumnType.TEXT }), | ||
new Column({ name: 'completed_at', type: ColumnType.TEXT }), | ||
new Column({ name: 'description', type: ColumnType.TEXT }), | ||
new Column({ name: 'completed', type: ColumnType.INTEGER }), | ||
new Column({ name: 'created_by', type: ColumnType.TEXT }), | ||
new Column({ name: 'completed_by', type: ColumnType.TEXT }) | ||
], | ||
indexes: [ | ||
new Index({ | ||
name: 'list', | ||
columns: [new IndexedColumn({ name: 'list_id' })] | ||
}) | ||
] | ||
}), | ||
new Table({ | ||
name: 'lists', | ||
columns: [ | ||
new Column({ name: 'created_at', type: ColumnType.TEXT }), | ||
new Column({ name: 'name', type: ColumnType.TEXT }), | ||
new Column({ name: 'owner_id', type: ColumnType.TEXT }) | ||
] | ||
}), | ||
// Add Attachment table | ||
new AttachmentTable() | ||
]); | ||
export type ListRecord = Database['lists']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.