Spaces:
Running
Running
Create shared/schema.ts (#6)
Browse files- Create shared/schema.ts (836ddd387b1a60f802e51e9a924dd630850e85bd)
- shared/schema.ts +18 -0
shared/schema.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { sql } from "drizzle-orm";
|
| 2 |
+
import { pgTable, text, varchar } from "drizzle-orm/pg-core";
|
| 3 |
+
import { createInsertSchema } from "drizzle-zod";
|
| 4 |
+
import { z } from "zod";
|
| 5 |
+
|
| 6 |
+
export const users = pgTable("users", {
|
| 7 |
+
id: varchar("id").primaryKey().default(sql`gen_random_uuid()`),
|
| 8 |
+
username: text("username").notNull().unique(),
|
| 9 |
+
password: text("password").notNull(),
|
| 10 |
+
});
|
| 11 |
+
|
| 12 |
+
export const insertUserSchema = createInsertSchema(users).pick({
|
| 13 |
+
username: true,
|
| 14 |
+
password: true,
|
| 15 |
+
});
|
| 16 |
+
|
| 17 |
+
export type InsertUser = z.infer<typeof insertUserSchema>;
|
| 18 |
+
export type User = typeof users.$inferSelect;
|