refactor(schema): Reorganize insert and select schema declarations
This commit reorganizes the insert and select schema declarations for improved readability. The declarations for 'UsersTable', 'ProductsTable', 'StocksTable', and 'CommentsTable' have been moved closer to their respective table schemas.
This commit is contained in:
parent
3ac89964ab
commit
1990bedcfd
@ -1,5 +1,6 @@
|
|||||||
import { pgTable } from "drizzle-orm/pg-core";
|
import { pgTable } from "drizzle-orm/pg-core";
|
||||||
import * as p from "drizzle-orm/pg-core";
|
import * as p from "drizzle-orm/pg-core";
|
||||||
|
import { z } from "zod"
|
||||||
import { createInsertSchema, createSelectSchema } from "drizzle-zod";
|
import { createInsertSchema, createSelectSchema } from "drizzle-zod";
|
||||||
|
|
||||||
|
|
||||||
@ -58,6 +59,9 @@ export const UsersTable = pgTable("users", {
|
|||||||
|
|
||||||
isAdmin: p.boolean("is_admin").default(false).notNull(),
|
isAdmin: p.boolean("is_admin").default(false).notNull(),
|
||||||
});
|
});
|
||||||
|
export const UsersTableSelectSchema = createSelectSchema(UsersTable)
|
||||||
|
export const UsersTableInsertSchema = createInsertSchema(UsersTable)
|
||||||
|
|
||||||
|
|
||||||
export const ProductsTable = pgTable("products", {
|
export const ProductsTable = pgTable("products", {
|
||||||
uuid: p.uuid("uuid").unique().primaryKey().defaultRandom().notNull(),
|
uuid: p.uuid("uuid").unique().primaryKey().defaultRandom().notNull(),
|
||||||
@ -94,6 +98,9 @@ export const ProductsTable = pgTable("products", {
|
|||||||
|
|
||||||
//playload of the description element
|
//playload of the description element
|
||||||
});
|
});
|
||||||
|
export const ProductsTableSelectSchema = createSelectSchema(ProductsTable);
|
||||||
|
export const ProductsTableInsertSchema = createInsertSchema(ProductsTable);
|
||||||
|
|
||||||
|
|
||||||
export const StocksTable = pgTable("stocks", {
|
export const StocksTable = pgTable("stocks", {
|
||||||
productId: p
|
productId: p
|
||||||
@ -103,6 +110,9 @@ export const StocksTable = pgTable("stocks", {
|
|||||||
|
|
||||||
quantity: p.integer("quantity").default(0).notNull(),
|
quantity: p.integer("quantity").default(0).notNull(),
|
||||||
});
|
});
|
||||||
|
export const StocksTableSelectSchema = createSelectSchema(StocksTable);
|
||||||
|
export const StocksTableInsertSchema = createInsertSchema(StocksTable);
|
||||||
|
|
||||||
|
|
||||||
export const CommentsTable = pgTable("comments", {
|
export const CommentsTable = pgTable("comments", {
|
||||||
productId: p
|
productId: p
|
||||||
@ -129,6 +139,9 @@ export const CommentsTable = pgTable("comments", {
|
|||||||
.defaultNow()
|
.defaultNow()
|
||||||
.notNull(),
|
.notNull(),
|
||||||
});
|
});
|
||||||
|
export const CommentsTableSelectSchema = createSelectSchema(CommentsTable);
|
||||||
|
export const CommentsTableInsertSchema = createInsertSchema(CommentsTable);
|
||||||
|
|
||||||
|
|
||||||
export const PurchaseHistory = pgTable("purchases", {
|
export const PurchaseHistory = pgTable("purchases", {
|
||||||
uuid: p.uuid("uuid").unique().primaryKey().defaultRandom().notNull(),
|
uuid: p.uuid("uuid").unique().primaryKey().defaultRandom().notNull(),
|
||||||
@ -160,18 +173,5 @@ export const PurchaseHistory = pgTable("purchases", {
|
|||||||
.defaultNow()
|
.defaultNow()
|
||||||
.notNull(),
|
.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 PurchaseHistorySelectSchema = createSelectSchema(PurchaseHistory);
|
||||||
export const PurchaseHistoryInsertSchema = createInsertSchema(PurchaseHistory);
|
export const PurchaseHistoryInsertSchema = createInsertSchema(PurchaseHistory);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user