Type errors with database connection

If I follow the exact example from the docs either:
import { drizzle } from "drizzle-orm/node-postgres"

const db = drizzle(process.env.DATABASE_URL);
const pool = db.$client;
import { drizzle } from "drizzle-orm/node-postgres"

const db = drizzle(process.env.DATABASE_URL);
const pool = db.$client;
or
import { drizzle } from "drizzle-orm/node-postgres";
import { Pool } from "pg";
const pool = new Pool({
connectionString: process.env.DATABASE_URL,
});
const db = drizzle({ client: pool });
import { drizzle } from "drizzle-orm/node-postgres";
import { Pool } from "pg";
const pool = new Pool({
connectionString: process.env.DATABASE_URL,
});
const db = drizzle({ client: pool });
I run into type errors. The only thing that works for me is:
const pool = new Pool({
connectionString: process.env.DATABASE_URL,
})

const db = drizzle(pool, { schema: schema })
const pool = new Pool({
connectionString: process.env.DATABASE_URL,
})

const db = drizzle(pool, { schema: schema })
Would love some clarity around this
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?