|
1 | 1 | import { Injectable } from '@angular/core'; |
2 | 2 | import { |
3 | | - AbstractPowerSyncDatabase, |
4 | | - Column, |
5 | | - ColumnType, |
| 3 | + column, |
| 4 | + CommonPowerSyncDatabase, |
6 | 5 | createConsoleLogger, |
7 | | - Index, |
8 | | - IndexedColumn, |
9 | 6 | LogLevels, |
10 | 7 | PowerSyncBackendConnector, |
11 | 8 | PowerSyncDatabase, |
@@ -36,35 +33,31 @@ export interface TodoRecord { |
36 | 33 | export const LISTS_TABLE = 'lists'; |
37 | 34 | export const TODOS_TABLE = 'todos'; |
38 | 35 |
|
39 | | -export const AppSchema = new Schema([ |
40 | | - new Table({ |
41 | | - name: TODOS_TABLE, |
42 | | - columns: [ |
43 | | - new Column({ name: 'list_id', type: ColumnType.TEXT }), |
44 | | - new Column({ name: 'created_at', type: ColumnType.TEXT }), |
45 | | - new Column({ name: 'completed_at', type: ColumnType.TEXT }), |
46 | | - new Column({ name: 'description', type: ColumnType.TEXT }), |
47 | | - new Column({ name: 'completed', type: ColumnType.INTEGER }), |
48 | | - new Column({ name: 'created_by', type: ColumnType.TEXT }), |
49 | | - new Column({ name: 'completed_by', type: ColumnType.TEXT }) |
50 | | - ], |
51 | | - indexes: [new Index({ name: 'list', columns: [new IndexedColumn({ name: 'list_id' })] })] |
52 | | - }), |
53 | | - new Table({ |
54 | | - name: LISTS_TABLE, |
55 | | - columns: [ |
56 | | - new Column({ name: 'created_at', type: ColumnType.TEXT }), |
57 | | - new Column({ name: 'name', type: ColumnType.TEXT }), |
58 | | - new Column({ name: 'owner_id', type: ColumnType.TEXT }) |
59 | | - ] |
| 36 | +export const AppSchema = new Schema({ |
| 37 | + [TODOS_TABLE]: new Table( |
| 38 | + { |
| 39 | + list_id: column.text, |
| 40 | + created_at: column.text, |
| 41 | + completed_at: column.text, |
| 42 | + description: column.text, |
| 43 | + completed: column.integer, |
| 44 | + created_by: column.text, |
| 45 | + completed_by: column.text |
| 46 | + }, |
| 47 | + { indexes: { list: ['list_id'] } } |
| 48 | + ), |
| 49 | + [LISTS_TABLE]: new Table({ |
| 50 | + created_at: column.text, |
| 51 | + name: column.text, |
| 52 | + owner_id: column.text |
60 | 53 | }) |
61 | | -]); |
| 54 | +}); |
62 | 55 |
|
63 | 56 | @Injectable({ |
64 | 57 | providedIn: 'root' |
65 | 58 | }) |
66 | 59 | export class PowerSyncService { |
67 | | - db: AbstractPowerSyncDatabase; |
| 60 | + db: CommonPowerSyncDatabase; |
68 | 61 |
|
69 | 62 | constructor() { |
70 | 63 | const factory = new WASQLiteOpenFactory({ |
|
0 commit comments