Skip to content

Commit d490626

Browse files
authored
Apply suggestions from code review
1 parent a244fa6 commit d490626

File tree

6 files changed

+53
-66
lines changed

6 files changed

+53
-66
lines changed

src/content/docs/hyperdrive/examples/connect-to-mysql/mysql-database-providers/planetscale.mdx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ With the host, database name, username and password, you can now create a Hyperd
3030

3131
:::note
3232

33-
When connection to a Planetscale database with Hyperdrive, you should use a driver like [node-postgres (pg)](/hyperdrive/examples/connect-to-postgres/postgres-drivers-and-libraries/node-postgres/) or [Postgres.js](/hyperdrive/examples/connect-to-postgres/postgres-drivers-and-libraries/postgres-js/)
34-
to connect directly to the underlying database instead of the [Planetscale serverless driver](https://planetscale.com/docs/tutorials/planetscale-serverless-driver). Hyperdrive is optimized for database access for Workers and
35-
will perform global connection pooling and fast query routing by connecting directly to your database.
33+
When connecting to a Planetscale database with Hyperdrive, you should use a driver like [node-postgres (pg)](/hyperdrive/examples/connect-to-postgres/postgres-drivers-and-libraries/node-postgres/) or [Postgres.js](/hyperdrive/examples/connect-to-postgres/postgres-drivers-and-libraries/postgres-js/) to connect directly to the underlying database instead of the [Planetscale serverless driver](https://planetscale.com/docs/tutorials/planetscale-serverless-driver). Hyperdrive is optimized for database access for Workers and will perform global connection pooling and fast query routing by connecting directly to your database.
3634

3735
:::
3836

src/content/docs/hyperdrive/examples/connect-to-mysql/mysql-drivers-and-libraries/drizzle-orm.mdx

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { Render } from "~/components";
1717
- A MySQL database
1818
- A [Hyperdrive configuration to your MySQL database](/hyperdrive/get-started/#3-connect-hyperdrive-to-a-database)
1919

20-
## Installation
20+
## 1. Install Drizzle
2121

2222
Install the Drizzle ORM and its dependencies such as the [mysql2](https://github.com/sidorares/node-mysql2) driver:
2323

@@ -31,11 +31,11 @@ Add the required Node.js compatibility flags and Hyperdrive binding to your `wra
3131

3232
<Render file="hyperdrive-node-compatibility-requirement" />
3333

34-
## Configure Drizzle
34+
## 2. Configure Drizzle
3535

36-
### Define a schema
36+
### 2.1 Define a schema
3737

38-
With Drizzle ORM, we define the schema in TypeScript rather than writing raw SQL. Here's how to define a users table:
38+
With Drizzle ORM, we define the schema in TypeScript rather than writing raw SQL. Here is how to define a `users` table:
3939

4040
```ts
4141
// src/schema.ts
@@ -49,10 +49,9 @@ export const users = mysqlTable("users", {
4949
});
5050
```
5151

52-
### Connect Drizzle ORM to the database with Hyperdrive
52+
### 2.2 Connect Drizzle ORM to the database with Hyperdrive
5353

54-
Use your the credentials of your Hyperdrive configuration for your database when using the
55-
Drizzle ORM within your Worker project as such:
54+
Use your the credentials of your Hyperdrive configuration for your database when using the Drizzle ORM within your Worker project as shown:
5655

5756
```ts
5857
// src/db/schema.ts
@@ -86,21 +85,18 @@ export default {
8685
} satisfies ExportedHandler<Env>;
8786
```
8887

89-
### Configure Drizzle-Kit for migrations (optional)
88+
### 2.3 Configure Drizzle-Kit for migrations (optional)
9089

91-
You can generate and run SQL migrations on your database based on your schema
92-
using Drizzle Kit CLI. Refer to [Drizzle ORM docs](https://orm.drizzle.team/docs/get-started/mysql-new) for additional guidance.
90+
You can generate and run SQL migrations on your database based on your schema using Drizzle Kit CLI. Refer to [Drizzle ORM docs](https://orm.drizzle.team/docs/get-started/mysql-new) for additional guidance.
9391

94-
1. Create a `.env` file and add your database connection string. The Drizzle Kit CLI will use
95-
this connection string to create and apply the migrations.
92+
1. Create a `.env` file and add your database connection string. The Drizzle Kit CLI will use this connection string to create and apply the migrations.
9693

9794
```toml
9895
# Replace with your direct database connection string
9996
DATABASE_URL='mysql://user:[email protected]/database-name'
10097
```
10198

102-
2. Create a `drizzle.config.ts` file in the root of your project to configure Drizzle Kit
103-
and add the following content:
99+
2. Create a `drizzle.config.ts` file in the root of your project to configure Drizzle Kit and add the following content:
104100

105101
```ts
106102
import 'dotenv/config';
@@ -115,8 +111,9 @@ using Drizzle Kit CLI. Refer to [Drizzle ORM docs](https://orm.drizzle.team/docs
115111
});
116112
```
117113

118-
3. Generate the migration file for your database according to your schema files and apply the migrations to your database.
119-
`bash
120-
npx drizzle-kit generate
121-
npx drizzle-kit migrate
122-
`
114+
3. Generate the migration file for your database according to your schema files and apply the migrations to your database.
115+
116+
```bash
117+
npx drizzle-kit generate
118+
npx drizzle-kit migrate
119+
```

src/content/docs/hyperdrive/examples/connect-to-postgres/postgres-database-providers/neon.mdx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,7 @@ With both the connection string and the password, you can now create a Hyperdriv
3131

3232
:::note
3333

34-
When connection to a Neon database with Hyperdrive, you should use a driver like [node-postgres (pg)](/hyperdrive/examples/connect-to-postgres/postgres-drivers-and-libraries/node-postgres/) or [Postgres.js](/hyperdrive/examples/connect-to-postgres/postgres-drivers-and-libraries/postgres-js/)
35-
to connect directly to the underlying database
36-
instead of the [Neon serverless driver](https://neon.tech/docs/serverless/serverless-driver). Hyperdrive is optimized for database access for Workers and
37-
will perform global connection pooling and fast query routing by connecting directly to your database.
34+
When connecting to a Neon database with Hyperdrive, you should use a driver like [node-postgres (pg)](/hyperdrive/examples/connect-to-postgres/postgres-drivers-and-libraries/node-postgres/) or [Postgres.js](/hyperdrive/examples/connect-to-postgres/postgres-drivers-and-libraries/postgres-js/) to connect directly to the underlying database instead of the [Neon serverless driver](https://neon.tech/docs/serverless/serverless-driver). Hyperdrive is optimized for database access for Workers and will perform global connection pooling and fast query routing by connecting directly to your database.
3835

3936
:::
4037

src/content/docs/hyperdrive/examples/connect-to-postgres/postgres-database-providers/supabase.mdx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@ With a database user, password, database endpoint (hostname and port) and databa
3434

3535
:::note
3636

37-
When connection to a Supabase database with Hyperdrive, you should use a driver like [node-postgres (pg)](/hyperdrive/examples/connect-to-postgres/postgres-drivers-and-libraries/node-postgres/) or [Postgres.js](/hyperdrive/examples/connect-to-postgres/postgres-drivers-and-libraries/postgres-js/)
38-
to connect directly to the underlying database instead of the [Supabase JavaScript client](https://github.com/supabase/supabase-js). Hyperdrive is optimized for database access for Workers and
39-
will perform global connection pooling and fast query routing by connecting directly to your database.
37+
When connecting to a Supabase database with Hyperdrive, you should use a driver like [node-postgres (pg)](/hyperdrive/examples/connect-to-postgres/postgres-drivers-and-libraries/node-postgres/) or [Postgres.js](/hyperdrive/examples/connect-to-postgres/postgres-drivers-and-libraries/postgres-js/) to connect directly to the underlying database instead of the [Supabase JavaScript client](https://github.com/supabase/supabase-js). Hyperdrive is optimized for database access for Workers and will perform global connection pooling and fast query routing by connecting directly to your database.
4038

4139
:::
4240

src/content/docs/hyperdrive/examples/connect-to-postgres/postgres-drivers-and-libraries/drizzle-orm.mdx

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ meta:
1515
- A PostgreSQL database
1616
- A [Hyperdrive configuration to your PostgreSQL database](/hyperdrive/get-started/#3-connect-hyperdrive-to-a-database)
1717

18-
## Installation
18+
## 1. Install Drizzle
1919

2020
Install the Drizzle ORM and its dependencies such as the [postgres](https://github.com/porsager/postgres) driver:
2121

@@ -29,11 +29,11 @@ Add the required Node.js compatibility flags and Hyperdrive binding to your `wra
2929

3030
<Render file="hyperdrive-node-compatibility-requirement" />
3131

32-
## Configure Drizzle
32+
## 2. Configure Drizzle
3333

34-
### Define a schema
34+
### 2.1 Define a schema
3535

36-
With Drizzle ORM, we define the schema in TypeScript rather than writing raw SQL. Here's how to define a users table:
36+
With Drizzle ORM, we define the schema in TypeScript rather than writing raw SQL. Here is how to define a `users` table:
3737

3838
```ts
3939
// src/db/schema.ts
@@ -47,10 +47,9 @@ export const users = pgTable("users", {
4747
});
4848
```
4949

50-
### Connect Drizzle ORM to the database with Hyperdrive
50+
### 2.2 Connect Drizzle ORM to the database with Hyperdrive
5151

52-
Use your Hyperdrive configuration for your database when using the
53-
Drizzle ORM within your Worker project as such:
52+
Use your Hyperdrive configuration for your database when using the Drizzle ORM within your Worker project as shown:
5453

5554
```ts
5655
// src/index.ts
@@ -81,21 +80,18 @@ export default {
8180
} satisfies ExportedHandler<Env>;
8281
```
8382

84-
### Configure Drizzle-Kit for migrations (optional)
83+
### 2.3 Configure Drizzle-Kit for migrations (optional)
8584

86-
You can generate and run SQL migrations on your database based on your schema
87-
using Drizzle Kit CLI. Refer to [Drizzle ORM docs](https://orm.drizzle.team/docs/get-started/postgresql) for additional guidance.
85+
You can generate and run SQL migrations on your database based on your schema using Drizzle Kit CLI. Refer to [Drizzle ORM docs](https://orm.drizzle.team/docs/get-started/postgresql) for additional guidance.
8886

89-
1. Create a `.env` file and add your database connection string. The Drizzle Kit CLI will use
90-
this connection string to create and apply the migrations.
87+
1. Create a `.env` file and add your database connection string. The Drizzle Kit CLI will use this connection string to create and apply the migrations.
9188

92-
```toml
93-
# Replace with your direct database connection string
94-
DATABASE_URL='postgres://user:[email protected]/database-name'
95-
```
89+
```toml
90+
# Replace with your direct database connection string
91+
DATABASE_URL='postgres://user:[email protected]/database-name'
92+
```
9693

97-
2. Create a `drizzle.config.ts` file in the root of your project to configure Drizzle Kit
98-
and add the following content:
94+
2. Create a `drizzle.config.ts` file in the root of your project to configure Drizzle Kit and add the following content:
9995

10096
```ts
10197
import "dotenv/config";
@@ -110,7 +106,8 @@ using Drizzle Kit CLI. Refer to [Drizzle ORM docs](https://orm.drizzle.team/docs
110106
});
111107
```
112108

113-
3. Generate the migration file for your database according to your schema files and apply the migrations to your database.
109+
3. Generate the migration file for your database according to your schema files and apply the migrations to your database.
110+
114111
```bash
115112
npx drizzle-kit generate
116113
npx drizzle-kit migrate

src/content/docs/hyperdrive/examples/connect-to-postgres/postgres-drivers-and-libraries/prisma-orm.mdx

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ meta:
1515
- A PostgreSQL database
1616
- A [Hyperdrive configuration to your PostgreSQL database](/hyperdrive/get-started/#3-connect-hyperdrive-to-a-database)
1717

18-
## Installation
18+
## 1. Install Prisma
1919

2020
Install Prisma, its dependencies, node-postgres driver, and generate the client:
2121

@@ -28,9 +28,9 @@ Add the required Node.js compatibility flags and Hyperdrive binding to your `wra
2828

2929
<Render file="hyperdrive-node-compatibility-requirement" />
3030

31-
## Configure Prisma
31+
## 2. Configure Prisma
3232

33-
### Define a schema
33+
### 2.1 Define a schema
3434

3535
With Prisma, we define the schema using the Prisma Schema Language (PSL). Create a `prisma/schema.prisma` file in your project:
3636

@@ -63,7 +63,7 @@ After defining your schema, generate the Prisma Client:
6363
npx prisma generate
6464
```
6565

66-
### Connect Prisma to the database with Hyperdrive
66+
### 2.2 Connect Prisma to the database with Hyperdrive
6767

6868
Use your Hyperdrive configuration for your database when using Prisma with the node-postgres adapter within your Worker project:
6969

@@ -122,23 +122,23 @@ export default {
122122
} satisfies ExportedHandler<Env>;
123123
```
124124

125-
### Prisma Migrations (optional)
125+
### 2.3 Migrate Prisma (optional)
126126

127127
You can use Prisma Migrate to create and manage your database schema:
128128

129-
1. Create a `.env` file in your project root with your direct database connection string:
130-
`toml
131-
DATABASE_URL='postgresql://user:[email protected]/database-name'
132-
`
129+
1. Create a `.env` file in your project root with your direct database connection string:
130+
```toml
131+
DATABASE_URL='postgresql://user:[email protected]/database-name'
132+
```
133133

134-
2. Initialize and generate your first migration (for development only):
135-
`sh
136-
npx prisma migrate dev --name init
137-
`
134+
2. Initialize and generate your first migration (for development only):
135+
```sh
136+
npx prisma migrate dev --name init
137+
```
138138

139-
This will create SQL migration files in the `prisma/migrations` directory and apply them to your database.
139+
This will create SQL migration files in the `prisma/migrations` directory and apply them to your database.
140140

141-
3. For production environments, apply migrations without generating new ones:
142-
`sh
143-
npx prisma migrate deploy
144-
`
141+
3. For production environments, apply migrations without generating new ones:
142+
```sh
143+
npx prisma migrate deploy
144+
```

0 commit comments

Comments
 (0)