Prisma Postgres 还拥有一个 无服务器驱动程序,未来将支持 Drizzle ORM。
Drizzle <> Prisma Postgres
本指南假定您熟悉
Prisma Postgres 是一个基于 unikernels 构建的无服务器数据库。它拥有大型免费套餐、基于操作的定价且没有冷启动。
您可以使用 PostgreSQL 的 node-postgres
或 postgres.js
驱动程序连接到它。
步骤 1 - 安装包
node-postgres (pg)
postgres.js
npm
yarn
pnpm
bun
npm i drizzle-orm pg
npm i -D drizzle-kit
步骤 2 - 初始化驱动程序并执行查询
node-postgres (pg)
postgres.js
// Make sure to install the 'pg' package
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 });
const result = await db.execute('select 1');