Quick start
For the quick start example we're going to use PostgresJS driver
Install the dependencies
npm i drizzle-orm postgres
npm i -D drizzle-kit
Declare your first schema file
schema.ts
import { pgTable, serial, text, varchar } from "drizzle-orm/pg-core";
export const users = pgTable('users', {
id: serial('id').primaryKey(),
fullName: text('full_name'),
phone: varchar('phone', { length: 256 }),
});
Run your first query, that's it!
index.ts
import { drizzle } from 'drizzle-orm/postgres-js';
import postgres from 'postgres';
import { users } from './schema';
const client = postgres(connectionString);
const db = drizzle(client);
const allUsers = await db.select().from(users);