From b014057da7b259559c75d30b3711974047b08140 Mon Sep 17 00:00:00 2001 From: mrevanzak Date: Mon, 27 Nov 2023 21:14:18 +0700 Subject: [PATCH] feat(api): approved column --- packages/api/src/router/product.ts | 1 + packages/db/schema/products.ts | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/api/src/router/product.ts b/packages/api/src/router/product.ts index 4f69961..702147a 100644 --- a/packages/api/src/router/product.ts +++ b/packages/api/src/router/product.ts @@ -28,6 +28,7 @@ export const productRouter = createTRPCRouter({ }, where: (products, { like, and, eq, gt }) => and( + eq(products.approved, true), like(products.name, `%${input.query.toLowerCase()}%`), gt(products.stock, 0), ...(input.categoryId diff --git a/packages/db/schema/products.ts b/packages/db/schema/products.ts index 31624d4..154ebd6 100644 --- a/packages/db/schema/products.ts +++ b/packages/db/schema/products.ts @@ -1,5 +1,5 @@ import { relations, sql } from "drizzle-orm"; -import { index, int, timestamp, varchar } from "drizzle-orm/mysql-core"; +import { boolean, index, int, timestamp, varchar } from "drizzle-orm/mysql-core"; import { createInsertSchema, createSelectSchema } from "drizzle-zod"; import { z } from "zod"; @@ -18,10 +18,11 @@ export const products = mySqlTable( .primaryKey() .default(sql`(UUID())`), name: varchar("name", { length: 256 }).notNull(), - description: varchar("description", { length: 256 }).notNull(), + description: varchar("description", { length: 256 }), price: int("price").notNull(), stock: int("stock").notNull(), image: varchar("image", { length: 256 }).notNull(), + approved: boolean("approved").notNull().default(false), sellerId: varchar("seller_id", { length: 36 }).notNull(), categoryId: varchar("category_id", { length: 255 }).notNull(), createdAt: timestamp("created_at")