Refactor to use hooks (#436)

This commit is contained in:
Jeremy 2024-10-11 18:00:22 +05:30 committed by GitHub
parent 124efca9a1
commit cb60f8b143
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
139 changed files with 8871 additions and 8726 deletions

24
db/schema.ts Normal file
View file

@ -0,0 +1,24 @@
import { Message } from "ai";
import { InferSelectModel } from "drizzle-orm";
import { pgTable, varchar, timestamp, json, uuid } from "drizzle-orm/pg-core";
export const user = pgTable("User", {
id: uuid("id").primaryKey().notNull().defaultRandom(),
email: varchar("email", { length: 64 }).notNull(),
password: varchar("password", { length: 64 }),
});
export type User = InferSelectModel<typeof user>;
export const chat = pgTable("Chat", {
id: uuid("id").primaryKey().notNull().defaultRandom(),
createdAt: timestamp("createdAt").notNull(),
messages: json("messages").notNull(),
userId: uuid("userId")
.notNull()
.references(() => user.id),
});
export type Chat = Omit<InferSelectModel<typeof chat>, "messages"> & {
messages: Array<Message>;
};