You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import { index, integer, sqliteTable, text } from'drizzle-orm/sqlite-core';
18
18
import { AppSchema } from'./schema';
19
19
@@ -29,27 +29,25 @@ export const todos = sqliteTable('todos', {
29
29
created_at:text('created_at')
30
30
});
31
31
32
-
exportconstlistsRelations=relations(lists, ({ one, many }) => ({
33
-
todos:many(todos)
34
-
}));
35
-
36
-
exportconsttodosRelations=relations(todos, ({ one, many }) => ({
37
-
list:one(lists, {
38
-
fields: [todos.list_id],
39
-
references: [lists.id]
40
-
})
32
+
exportconstrelations=defineRelations({ lists, todos }, (r) => ({
33
+
lists: {
34
+
todos:r.many.todos({
35
+
from:r.lists.id,
36
+
to:r.todos.list_id
37
+
})
38
+
},
39
+
todos: {
40
+
list:r.one.lists({
41
+
from:r.todos.list_id,
42
+
to:r.lists.id,
43
+
optional:false
44
+
})
45
+
}
41
46
}));
42
47
43
-
exportconstdrizzleSchema= {
44
-
lists,
45
-
todos,
46
-
listsRelations,
47
-
todosRelations
48
-
};
49
-
50
48
// As an alternative to manually defining a PowerSync schema, generate the local PowerSync schema from the Drizzle schema with the `DrizzleAppSchema` constructor:
51
49
// import { DrizzleAppSchema } from '@powersync/drizzle-driver';
52
-
// export const AppSchema = new DrizzleAppSchema(drizzleSchema);
50
+
// export const AppSchema = new DrizzleAppSchema({ lists, todos });
53
51
//
54
52
// This is optional, but recommended, since you will only need to maintain one schema on the client-side
55
53
// Read on to learn more.
@@ -63,7 +61,17 @@ export const powerSyncDb = new PowerSyncDatabase({
0 commit comments