Prisma Postgres 也有一个 无服务器驱动程序,未来 Drizzle ORM 将支持该功能。
Drizzle <> Prisma Postgres
This guide assumes familiarity with:
Prisma Postgres 是一个基于 unikernels 构建的无服务器数据库。它有一个很大的免费层级 基于操作的定价,并且没有冷启动。
你可以使用 PostgreSQL 的 node-postgres
或 postgres.js
驱动程序连接到它。
步骤 1 - 安装软件包
node-postgres (pg)
postgres.js
npm
yarn
pnpm
bun
npm i drizzle-orm pg -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');