From 4938247ba57735db3d573f6d0d528b744f410020 Mon Sep 17 00:00:00 2001 From: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> Date: Fri, 28 Nov 2025 07:33:37 +0600 Subject: [PATCH 1/3] docs: add connector docs for prisma postgres --- docs/2.connectors/prismapostgres.md | 83 +++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 docs/2.connectors/prismapostgres.md diff --git a/docs/2.connectors/prismapostgres.md b/docs/2.connectors/prismapostgres.md new file mode 100644 index 0000000..989239e --- /dev/null +++ b/docs/2.connectors/prismapostgres.md @@ -0,0 +1,83 @@ +--- +icon: simple-icons:prisma +--- + +# Prisma Postgres + +> Connect DB0 to Prisma Postgres + +[Prisma Postgres](https://www.prisma.io/postgres?utm_source=db0&utm_campaign=ppg-awareness) provides a fast, managed PostgreSQL database service. While there's no specific DB0 connector for Prisma Postgres, you can use the existing PostgreSQL connector to connect smoothly. + +## Create Database + +You can either create an account in [Prisma Data Platform](https://console.prisma.io?utm_source=db0&utm_campaign=ppg-awareness) and create a database manually or [use `create-db` cli tool](https://www.prisma.io/docs/postgres/introduction/npx-create-db?utm_source=db0&utm_campaign=ppg-awareness) to create a Prisma Postgres database. + +Let's create a new Prisma Postgres database using the `create-db` cli tool: + +```terminal +npx create-db +``` + +This will output something like: + +```terminal +┌ 🚀 Creating a Prisma Postgres database +│ +│ Provisioning a temporary database in us-east-1... +│ +│ It will be automatically deleted in 24 hours, but you can claim it. +│ +◇ Database created successfully! +│ +│ +● Database Connection +│ +│ +│ Connection String: +│ +│ postgresql://username:password@db.prisma.io:5432/postgres?sslmode=require +│ +│ +◆ Claim Your Database +│ +│ Keep your database for free: +│ +│ https://create-db.prisma.io/claim?projectID=your_project_id&utm_source=db0&utm_campaign=ppg-awareness +│ +│ Database will be deleted on [DATE] if not claimed. +│ +└ +``` + +**Important:** Save your actual connection string to an `.env` file: + +```bash +DATABASE_URL="postgresql://your_username:your_password@db.prisma.io:5432/postgres?sslmode=require" +``` + +## Installation + +Install the PostgreSQL driver: + +:pm-install{name="pg @types/pg"} + +## Usage + +Install [`db0`](https://npmjs.com/package/db0) npm package: + +:pm-install{name="db0"} + +Use the [`postgresql`](/connectors/postgresql) connector with your Prisma Postgres database: + +```js +import { createDatabase } from "db0"; +import postgresql from "db0/connectors/postgresql"; + +const db = createDatabase( + postgresql({ + url: process.env.DATABASE_URL, + }), +); +``` + +Then you should be able to query your Prisma Postgres database. From 51e6fc2e511ce3160c215ba0c09e12579c17041f Mon Sep 17 00:00:00 2001 From: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> Date: Fri, 28 Nov 2025 18:42:37 +0600 Subject: [PATCH 2/3] feat: add example --- docs/2.connectors/prismapostgres.md | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/docs/2.connectors/prismapostgres.md b/docs/2.connectors/prismapostgres.md index 989239e..764b258 100644 --- a/docs/2.connectors/prismapostgres.md +++ b/docs/2.connectors/prismapostgres.md @@ -70,6 +70,7 @@ Install [`db0`](https://npmjs.com/package/db0) npm package: Use the [`postgresql`](/connectors/postgresql) connector with your Prisma Postgres database: ```js +import "dotenv/config"; import { createDatabase } from "db0"; import postgresql from "db0/connectors/postgresql"; @@ -80,4 +81,22 @@ const db = createDatabase( ); ``` -Then you should be able to query your Prisma Postgres database. +Then you should be able to query your Prisma Postgres database: + +```typescript +import "dotenv/config"; +import { createDatabase } from "db0"; +import postgresql from "db0/connectors/postgresql"; + +const db = createDatabase( + postgresql({ + url: process.env.DATABASE_URL!, + }), +); + +async function main() { + console.log(await db.sql`SELECT 1`); +} + +main(); +``` From 0395474964ae60d695e431b0efe01287b3db8753 Mon Sep 17 00:00:00 2001 From: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> Date: Tue, 9 Dec 2025 15:18:21 +0600 Subject: [PATCH 3/3] docs: move prisma postgres into postgres connector --- docs/2.connectors/1.index.md | 1 + docs/2.connectors/postgresql.md | 87 ++++++++++++++++++++++++ docs/2.connectors/prismapostgres.md | 102 ---------------------------- 3 files changed, 88 insertions(+), 102 deletions(-) delete mode 100644 docs/2.connectors/prismapostgres.md diff --git a/docs/2.connectors/1.index.md b/docs/2.connectors/1.index.md index f993a90..0f367d7 100644 --- a/docs/2.connectors/1.index.md +++ b/docs/2.connectors/1.index.md @@ -13,6 +13,7 @@ Currently supported connectors: - [LibSQL](/connectors/libsql) - [PlanetScale](/connectors/planetscale) - [PostgreSQL](/connectors/postgresql) +- [Prisma Postgres](/connectors/postgresql#prisma-postgres) - [MySQL](/connectors/mysql) - [SQLite](/connectors/sqlite) diff --git a/docs/2.connectors/postgresql.md b/docs/2.connectors/postgresql.md index 0482ba0..7e15223 100644 --- a/docs/2.connectors/postgresql.md +++ b/docs/2.connectors/postgresql.md @@ -36,3 +36,90 @@ Connection URL string. Alternatively, you can add connection configuration. :read-more{title="node-postgres client options" to="https://node-postgres.com/apis/client#new-client"} + +## Prisma Postgres + +[Prisma Postgres](https://www.prisma.io/postgres?utm_source=db0&utm_campaign=ppg-awareness) provides a fast, managed PostgreSQL database service. While there's no specific DB0 connector for Prisma Postgres, you can use the existing PostgreSQL connector to connect smoothly. + +### Create a database + +You can either create an account in [Prisma Data Platform](https://console.prisma.io?utm_source=db0&utm_campaign=ppg-awareness) and create a database manually or [use `create-db` cli tool](https://www.prisma.io/docs/postgres/introduction/npx-create-db?utm_source=db0&utm_campaign=ppg-awareness) to create a Prisma Postgres database. + +Let's create a new Prisma Postgres database using the `create-db` cli tool: + +```terminal +npx create-db +``` + +This will output something like: + +```terminal +┌ 🚀 Creating a Prisma Postgres database +│ +│ Provisioning a temporary database in us-east-1... +│ +│ It will be automatically deleted in 24 hours, but you can claim it. +│ +◇ Database created successfully! +│ +│ +● Database Connection +│ +│ +│ Connection String: +│ +│ postgresql://username:password@db.prisma.io:5432/postgres?sslmode=require +│ +│ +◆ Claim Your Database +│ +│ Keep your database for free: +│ +│ https://create-db.prisma.io/claim?projectID=your_project_id&utm_source=db0&utm_campaign=ppg-awareness +│ +│ Database will be deleted on [DATE] if not claimed. +│ +└ +``` + +**Important:** Save your actual connection string to an `.env` file: + +```bash +DATABASE_URL="postgresql://your_username:your_password@db.prisma.io:5432/postgres?sslmode=require" +``` + +### Usage + +Use the postgresql connector with your Prisma Postgres database: + +```js +import "dotenv/config"; +import { createDatabase } from "db0"; +import postgresql from "db0/connectors/postgresql"; + +const db = createDatabase( + postgresql({ + url: process.env.DATABASE_URL, + }), +); +``` + +Then you should be able to query your Prisma Postgres database: + +```typescript +import "dotenv/config"; +import { createDatabase } from "db0"; +import postgresql from "db0/connectors/postgresql"; + +const db = createDatabase( + postgresql({ + url: process.env.DATABASE_URL!, + }), +); + +async function main() { + console.log(await db.sql`SELECT 1`); +} + +main(); +``` diff --git a/docs/2.connectors/prismapostgres.md b/docs/2.connectors/prismapostgres.md deleted file mode 100644 index 764b258..0000000 --- a/docs/2.connectors/prismapostgres.md +++ /dev/null @@ -1,102 +0,0 @@ ---- -icon: simple-icons:prisma ---- - -# Prisma Postgres - -> Connect DB0 to Prisma Postgres - -[Prisma Postgres](https://www.prisma.io/postgres?utm_source=db0&utm_campaign=ppg-awareness) provides a fast, managed PostgreSQL database service. While there's no specific DB0 connector for Prisma Postgres, you can use the existing PostgreSQL connector to connect smoothly. - -## Create Database - -You can either create an account in [Prisma Data Platform](https://console.prisma.io?utm_source=db0&utm_campaign=ppg-awareness) and create a database manually or [use `create-db` cli tool](https://www.prisma.io/docs/postgres/introduction/npx-create-db?utm_source=db0&utm_campaign=ppg-awareness) to create a Prisma Postgres database. - -Let's create a new Prisma Postgres database using the `create-db` cli tool: - -```terminal -npx create-db -``` - -This will output something like: - -```terminal -┌ 🚀 Creating a Prisma Postgres database -│ -│ Provisioning a temporary database in us-east-1... -│ -│ It will be automatically deleted in 24 hours, but you can claim it. -│ -◇ Database created successfully! -│ -│ -● Database Connection -│ -│ -│ Connection String: -│ -│ postgresql://username:password@db.prisma.io:5432/postgres?sslmode=require -│ -│ -◆ Claim Your Database -│ -│ Keep your database for free: -│ -│ https://create-db.prisma.io/claim?projectID=your_project_id&utm_source=db0&utm_campaign=ppg-awareness -│ -│ Database will be deleted on [DATE] if not claimed. -│ -└ -``` - -**Important:** Save your actual connection string to an `.env` file: - -```bash -DATABASE_URL="postgresql://your_username:your_password@db.prisma.io:5432/postgres?sslmode=require" -``` - -## Installation - -Install the PostgreSQL driver: - -:pm-install{name="pg @types/pg"} - -## Usage - -Install [`db0`](https://npmjs.com/package/db0) npm package: - -:pm-install{name="db0"} - -Use the [`postgresql`](/connectors/postgresql) connector with your Prisma Postgres database: - -```js -import "dotenv/config"; -import { createDatabase } from "db0"; -import postgresql from "db0/connectors/postgresql"; - -const db = createDatabase( - postgresql({ - url: process.env.DATABASE_URL, - }), -); -``` - -Then you should be able to query your Prisma Postgres database: - -```typescript -import "dotenv/config"; -import { createDatabase } from "db0"; -import postgresql from "db0/connectors/postgresql"; - -const db = createDatabase( - postgresql({ - url: process.env.DATABASE_URL!, - }), -); - -async function main() { - console.log(await db.sql`SELECT 1`); -} - -main(); -```