Skip to content

Commit

Permalink
chore: update schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
DominicGBauer committed Feb 29, 2024
1 parent 85cda62 commit ceb4a1f
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 58 deletions.
2 changes: 1 addition & 1 deletion demos/angular-supabase-todolist/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@angular/platform-browser-dynamic": "^17.0.4",
"@angular/router": "^17.0.4",
"@angular/service-worker": "^17.0.4",
"@journeyapps/powersync-sdk-web": "^0.0.3",
"@journeyapps/powersync-sdk-web": "workspace:*",
"@journeyapps/wa-sqlite": "^0.0.2",
"@supabase/supabase-js": "^2.38.5",
"rxjs": "~7.8.1",
Expand Down
21 changes: 12 additions & 9 deletions demos/nextjs-supabase-todolist/src/library/powersync/AppSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@ import { column, Schema, TableV2 } from '@journeyapps/powersync-sdk-web';
export const LISTS_TABLE = 'lists';
export const TODOS_TABLE = 'todos';

const todos = new TableV2({
list_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
});
const todos = new TableV2(
{
list_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'] } }
);

const lists = new TableV2({
created_at: column.text,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
import { Column, ColumnType, Index, IndexedColumn, Schema, Table } from '@journeyapps/powersync-sdk-web';
import { column, Schema, TableV2 } from '@journeyapps/powersync-sdk-web';

export const AppSchema = new Schema([
new Table({
name: 'documents',
columns: [
new Column({ name: 'title', type: ColumnType.TEXT }),
new Column({ name: 'created_at', type: ColumnType.TEXT })
]
}),
new Table({
name: 'document_updates',
columns: [
new Column({ name: 'created_at', type: ColumnType.TEXT }),
new Column({ name: 'document_id', type: ColumnType.TEXT }),
new Column({ name: 'update_b64', type: ColumnType.TEXT })
],
indexes: [new Index({ name: 'by_document', columns: [new IndexedColumn({ name: 'document_id' })] })]
})
]);
const documents = new TableV2(
{
title: column.text,
created_at: column.text
},
{ indexes: { list: ['list_id'] } }
);

const document_updates = new TableV2(
{
document_id: column.text,
created_at: column.text,
update_b64: column.text
},
{ indexes: { by_document: ['document_id'] } }
);

export const AppSchema = new Schema({
documents,
document_updates
});

export type Database = (typeof AppSchema)['types'];
export type Documents = Database['documents'];

export type DocumentUpdates = Database['document_updates'];
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
import {
SupabaseClient,
createClient,
PostgrestError,
FunctionsHttpError,
FunctionsRelayError,
FunctionsFetchError
Expand Down
31 changes: 3 additions & 28 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ceb4a1f

Please sign in to comment.