drizzle supabase #2

Merged
afiqzudinhadi merged 14 commits from drizzle-supabase into main 2025-07-10 14:49:08 +08:00
6 changed files with 18 additions and 14 deletions
Showing only changes of commit 52bfa28fcd - Show all commits

View file

@ -1,2 +1,2 @@
export * from "./schema/users";
export * from "./schema/products";
export * from "./queries/users";
export * from "./queries/products";

View file

@ -1,6 +1,10 @@
import { db } from "../database";
import { InsertProduct, product } from "../schema/products";
import { InsertProduct, products } from "../schema/products";
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);
}

View file

@ -1,7 +1,7 @@
import { pgTable, serial, text, numeric, boolean } from "drizzle-orm/pg-core";
import { timestamps } from "./column.helpers";
export const product = pgTable("products", {
export const products = pgTable("products", {
id: serial("id").primaryKey(),
name: text("name").notNull(),
description: text("description"),
@ -11,5 +11,5 @@ export const product = pgTable("products", {
...timestamps,
});
export type InsertProduct = typeof product.$inferInsert;
export type SelectProduct = typeof product.$inferSelect;
export type InsertProduct = typeof products.$inferInsert;
export type SelectProduct = typeof products.$inferSelect;

View file

@ -1,7 +1,7 @@
import { pgTable, text } from "drizzle-orm/pg-core";
import { timestamps } from "./column.helpers";
export const user = pgTable("users", {
export const users = pgTable("users", {
id: text("id").primaryKey(), // Clerk user ID
email: text("email").notNull(),
name: text("name"),
@ -9,5 +9,5 @@ export const user = pgTable("users", {
...timestamps,
});
export type InsertUser = typeof user.$inferInsert;
export type SelectUser = typeof user.$inferSelect;
export type InsertUser = typeof users.$inferInsert;
export type SelectUser = typeof users.$inferSelect;

View file

@ -1,6 +1,6 @@
import { faker } from "@faker-js/faker";
import { db } from "../database";
import { product } from "../schema/products";
import { products } from "../schema/products";
import type { SeedFunction } from "./seed";
type ProductRow = {
@ -23,7 +23,7 @@ export const seedProducts: SeedFunction = async () => {
isPublished: faker.datatype.boolean(),
}));
await db.insert(product).values(data);
await db.insert(products).values(data);
return `${data.length} Products seeded successfully`;
};

View file

@ -1,6 +1,6 @@
import { faker } from "@faker-js/faker";
import { db } from "../database";
import { user } from "../schema/users";
import { users } from "../schema/users";
import type { SeedFunction } from "./seed";
type UserRow = {
@ -17,7 +17,7 @@ export const seedUsers: SeedFunction = async () => {
email: faker.internet.email(),
}));
await db.insert(user).values(data);
await db.insert(users).values(data);
return `${data.length} Users seeded successfully`;
};