Contoh Konversi: PostgreSQL DDL → Drizzle pgTable
Input (PostgreSQL DDL)
CREATE TABLE orders (
id SERIAL PRIMARY KEY,
total_amount NUMERIC(10,2) NOT NULL
); Output (Drizzle pgTable)
import { pgTable, serial, numeric } from "drizzle-orm/pg-core";
export const orders = pgTable("orders", {
id: serial("id").primaryKey(),
totalAmount: numeric("total_amount", { precision: 10, scale: 2 }).notNull(),
}); Pertanyaan yang Sering Diajukan (FAQ)
Bisakah saya mengekspor tipe TypeScript dengan Drizzle?
Ya! Drizzle menyediakan helper tipe InferSelectModel<typeof table> untuk melakukan inferensi tipe database secara otomatis.