-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
DominicGBauer
committed
Feb 29, 2024
1 parent
85cda62
commit ceb4a1f
Showing
5 changed files
with
43 additions
and
58 deletions.
There are no files selected for viewing
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
46 changes: 27 additions & 19 deletions
46
demos/yjs-nextjs-supabase-text-collab/src/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,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']; |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.