mirror of
https://github.com/khairul169/code-share.git
synced 2025-04-29 00:59:37 +07:00
22 lines
782 B
TypeScript
22 lines
782 B
TypeScript
import { sql } from "drizzle-orm";
|
|
import { integer, sqliteTable, text } from "drizzle-orm/sqlite-core";
|
|
import { createInsertSchema, createSelectSchema } from "drizzle-zod";
|
|
import { z } from "zod";
|
|
|
|
export const user = sqliteTable("users", {
|
|
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
name: text("name").notNull(),
|
|
email: text("email").notNull().unique(),
|
|
password: text("password").notNull(),
|
|
createdAt: text("created_at")
|
|
.notNull()
|
|
.default(sql`CURRENT_TIMESTAMP`),
|
|
deletedAt: text("deleted_at"),
|
|
});
|
|
|
|
export const insertUserSchema = createInsertSchema(user);
|
|
export const selectUserSchema = createSelectSchema(user);
|
|
|
|
export type UserWithPassword = z.infer<typeof selectUserSchema>;
|
|
export type UserSchema = Omit<UserWithPassword, "password">;
|