Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion docs/ts/develop/orms/drizzle.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ In `database.ts`, initialize the `SQLDatabase` and configure Drizzle:
import { api } from "encore.dev/api";
import { SQLDatabase } from "encore.dev/storage/sqldb";
import { drizzle } from "drizzle-orm/node-postgres";
import { Pool } from 'pg';
import { users } from "./schema";
import * as schema from './schema'; // Your entire drizzle schema

// Create SQLDatabase instance with migrations configuration
const db = new SQLDatabase("test", {
Expand All @@ -27,8 +29,12 @@ const db = new SQLDatabase("test", {
},
});

const pool = new Pool({
connectionString: db.connectionString,
});

// Initialize Drizzle ORM with the connection string
const orm = drizzle(db.connectionString);
const orm = drizzle(pool, { schema });

// Query all users
await orm.select().from(users);
Expand Down