Skip to content

Commit

Permalink
feat(api): approved column
Browse files Browse the repository at this point in the history
  • Loading branch information
mrevanzak committed Nov 27, 2023
1 parent ed35d3e commit b014057
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/api/src/router/product.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions packages/db/schema/products.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand All @@ -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")
Expand Down

0 comments on commit b014057

Please sign in to comment.