diff --git a/src/schema.ts b/src/schema.ts index 94fdaee..74b4766 100644 --- a/src/schema.ts +++ b/src/schema.ts @@ -1,5 +1,6 @@ import { pgTable } from "drizzle-orm/pg-core"; import * as p from "drizzle-orm/pg-core"; +import { z } from "zod" import { createInsertSchema, createSelectSchema } from "drizzle-zod"; @@ -58,6 +59,9 @@ export const UsersTable = pgTable("users", { isAdmin: p.boolean("is_admin").default(false).notNull(), }); +export const UsersTableSelectSchema = createSelectSchema(UsersTable) +export const UsersTableInsertSchema = createInsertSchema(UsersTable) + export const ProductsTable = pgTable("products", { uuid: p.uuid("uuid").unique().primaryKey().defaultRandom().notNull(), @@ -94,6 +98,9 @@ export const ProductsTable = pgTable("products", { //playload of the description element }); +export const ProductsTableSelectSchema = createSelectSchema(ProductsTable); +export const ProductsTableInsertSchema = createInsertSchema(ProductsTable); + export const StocksTable = pgTable("stocks", { productId: p @@ -103,6 +110,9 @@ export const StocksTable = pgTable("stocks", { quantity: p.integer("quantity").default(0).notNull(), }); +export const StocksTableSelectSchema = createSelectSchema(StocksTable); +export const StocksTableInsertSchema = createInsertSchema(StocksTable); + export const CommentsTable = pgTable("comments", { productId: p @@ -129,6 +139,9 @@ export const CommentsTable = pgTable("comments", { .defaultNow() .notNull(), }); +export const CommentsTableSelectSchema = createSelectSchema(CommentsTable); +export const CommentsTableInsertSchema = createInsertSchema(CommentsTable); + export const PurchaseHistory = pgTable("purchases", { uuid: p.uuid("uuid").unique().primaryKey().defaultRandom().notNull(), @@ -160,18 +173,5 @@ export const PurchaseHistory = pgTable("purchases", { .defaultNow() .notNull(), }); - -export const UsersTableSelectSchema = createSelectSchema(UsersTable) -export const UsersTableInsertSchema = createInsertSchema(UsersTable) - -export const ProductsTableSelectSchema = createSelectSchema(ProductsTable); -export const ProductsTableInsertSchema = createInsertSchema(ProductsTable); - -export const StocksTableSelectSchema = createSelectSchema(StocksTable); -export const StocksTableInsertSchema = createInsertSchema(StocksTable); - -export const CommentsTableSelectSchema = createSelectSchema(CommentsTable); -export const CommentsTableInsertSchema = createInsertSchema(CommentsTable); - export const PurchaseHistorySelectSchema = createSelectSchema(PurchaseHistory); export const PurchaseHistoryInsertSchema = createInsertSchema(PurchaseHistory);