Exemple de conversion : PostgreSQL DDL → Drizzle pgTable
Entrée (PostgreSQL DDL)
CREATE TABLE orders (
id SERIAL PRIMARY KEY,
total_amount NUMERIC(10,2) NOT NULL
); Sortie (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(),
}); Questions fréquentes (FAQ)
Peut-on exporter les types TypeScript depuis Drizzle ?
Oui ! Drizzle fournit type InferSelectModel<typeof table> pour inférer automatiquement les types de vos tables.