chore: update table var to follow table name in db
This commit is contained in:
parent
a6fc74e851
commit
52bfa28fcd
6 changed files with 18 additions and 14 deletions
|
|
@ -1,2 +1,2 @@
|
||||||
export * from "./schema/users";
|
export * from "./queries/users";
|
||||||
export * from "./schema/products";
|
export * from "./queries/products";
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,10 @@
|
||||||
import { db } from "../database";
|
import { db } from "../database";
|
||||||
import { InsertProduct, product } from "../schema/products";
|
import { InsertProduct, products } from "../schema/products";
|
||||||
|
|
||||||
export async function createProduct(data: InsertProduct) {
|
export async function createProduct(data: InsertProduct) {
|
||||||
await db.insert(product).values(data);
|
await db.insert(products).values(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getProducts() {
|
||||||
|
return db.select().from(products);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { pgTable, serial, text, numeric, boolean } from "drizzle-orm/pg-core";
|
import { pgTable, serial, text, numeric, boolean } from "drizzle-orm/pg-core";
|
||||||
import { timestamps } from "./column.helpers";
|
import { timestamps } from "./column.helpers";
|
||||||
|
|
||||||
export const product = pgTable("products", {
|
export const products = pgTable("products", {
|
||||||
id: serial("id").primaryKey(),
|
id: serial("id").primaryKey(),
|
||||||
name: text("name").notNull(),
|
name: text("name").notNull(),
|
||||||
description: text("description"),
|
description: text("description"),
|
||||||
|
|
@ -11,5 +11,5 @@ export const product = pgTable("products", {
|
||||||
...timestamps,
|
...timestamps,
|
||||||
});
|
});
|
||||||
|
|
||||||
export type InsertProduct = typeof product.$inferInsert;
|
export type InsertProduct = typeof products.$inferInsert;
|
||||||
export type SelectProduct = typeof product.$inferSelect;
|
export type SelectProduct = typeof products.$inferSelect;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { pgTable, text } from "drizzle-orm/pg-core";
|
import { pgTable, text } from "drizzle-orm/pg-core";
|
||||||
import { timestamps } from "./column.helpers";
|
import { timestamps } from "./column.helpers";
|
||||||
|
|
||||||
export const user = pgTable("users", {
|
export const users = pgTable("users", {
|
||||||
id: text("id").primaryKey(), // Clerk user ID
|
id: text("id").primaryKey(), // Clerk user ID
|
||||||
email: text("email").notNull(),
|
email: text("email").notNull(),
|
||||||
name: text("name"),
|
name: text("name"),
|
||||||
|
|
@ -9,5 +9,5 @@ export const user = pgTable("users", {
|
||||||
...timestamps,
|
...timestamps,
|
||||||
});
|
});
|
||||||
|
|
||||||
export type InsertUser = typeof user.$inferInsert;
|
export type InsertUser = typeof users.$inferInsert;
|
||||||
export type SelectUser = typeof user.$inferSelect;
|
export type SelectUser = typeof users.$inferSelect;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { faker } from "@faker-js/faker";
|
import { faker } from "@faker-js/faker";
|
||||||
import { db } from "../database";
|
import { db } from "../database";
|
||||||
import { product } from "../schema/products";
|
import { products } from "../schema/products";
|
||||||
import type { SeedFunction } from "./seed";
|
import type { SeedFunction } from "./seed";
|
||||||
|
|
||||||
type ProductRow = {
|
type ProductRow = {
|
||||||
|
|
@ -23,7 +23,7 @@ export const seedProducts: SeedFunction = async () => {
|
||||||
isPublished: faker.datatype.boolean(),
|
isPublished: faker.datatype.boolean(),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
await db.insert(product).values(data);
|
await db.insert(products).values(data);
|
||||||
|
|
||||||
return `${data.length} Products seeded successfully`;
|
return `${data.length} Products seeded successfully`;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { faker } from "@faker-js/faker";
|
import { faker } from "@faker-js/faker";
|
||||||
import { db } from "../database";
|
import { db } from "../database";
|
||||||
import { user } from "../schema/users";
|
import { users } from "../schema/users";
|
||||||
import type { SeedFunction } from "./seed";
|
import type { SeedFunction } from "./seed";
|
||||||
|
|
||||||
type UserRow = {
|
type UserRow = {
|
||||||
|
|
@ -17,7 +17,7 @@ export const seedUsers: SeedFunction = async () => {
|
||||||
email: faker.internet.email(),
|
email: faker.internet.email(),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
await db.insert(user).values(data);
|
await db.insert(users).values(data);
|
||||||
|
|
||||||
return `${data.length} Users seeded successfully`;
|
return `${data.length} Users seeded successfully`;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue