The best way to control Claude Code, Codex and more from any computer or phone

main
ts 30 lines 848 Bytes
Raw
1 import { defineRelations } from "drizzle-orm";
2 import { integer, sqliteTable, text } from "drizzle-orm/sqlite-core";
3
4 export const Users = sqliteTable("users", {
5 id: integer("id").primaryKey({ autoIncrement: true }),
6 email: text("email").notNull().unique(),
7 name: text("name").notNull(),
8 });
9 export type User = typeof Users.$inferSelect;
10
11 export const Posts = sqliteTable("posts", {
12 id: integer("id").primaryKey({ autoIncrement: true }),
13 userId: integer("user_id")
14 .notNull()
15 .references(() => Users.id, { onDelete: "cascade" }),
16 title: text("title").notNull(),
17 });
18 export type Post = typeof Posts.$inferSelect;
19
20 export const relations = defineRelations({ Users, Posts }, (t) => ({
21 Users: {
22 posts: t.many.Posts(),
23 },
24 Posts: {
25 user: t.one.Users({
26 from: t.Posts.userId,
27 to: t.Users.id,
28 }),
29 },
30 }));