Skip to content

Commit

Permalink
[Hyperdrive] nodejs_compat update (#17486)
Browse files Browse the repository at this point in the history
* Adding a new partial for compatibility_flags and compatibility_date.

* Using partial file in the relevant location.

* Revert "Using partial file in the relevant location."

This reverts commit de132a3.

* Update src/content/docs/hyperdrive/tutorials/serverless-timeseries-api-with-timescale/index.mdx

* Updating the compatibility reference in the table.

* Update src/content/docs/hyperdrive/configuration/connect-to-postgres.mdx

* Update src/content/docs/hyperdrive/configuration/connect-to-postgres.mdx

---------

Co-authored-by: Thomas Gauvin <35609369+thomasgauvin@users.noreply.github.com>
  • Loading branch information
Oxyjun and thomasgauvin authored Oct 11, 2024
1 parent 0060ab7 commit cbc4f3d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ The command above will output the ID of your Hyperdrive, which you will need to

```toml
# required for database drivers to function
compatibility_flags = [ "nodejs_compat_v2" ]
compatibility_flags = ["nodejs_compat"]
compatibility_date = "2024-09-23"

[[hyperdrive]]
binding = "HYPERDRIVE"
Expand All @@ -48,7 +49,7 @@ Hyperdrive uses Workers [TCP socket support](/workers/runtime-apis/tcp-sockets/#
| Driver | Documentation | Minimum Version Required | Notes |
| ----------------------------- | ---------------------------------------------------------------------------- | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Postgres.js (**recommended**) | [https://github.com/porsager/postgres](https://github.com/porsager/postgres) | `postgres@3.4.4` | Supported in both Workers & Pages. |
| node-postgres - `pg` | [https://node-postgres.com/](https://node-postgres.com/) | `pg@8.13.0` | `8.11.4` introduced a bug with URL parsing and will not work. `8.11.5` fixes this. Requires the [`nodejs_compat_v2`](/workers/runtime-apis/nodejs/) compatibility flag to be set. Requires wrangler `3.78.7` or later. |
| node-postgres - `pg` | [https://node-postgres.com/](https://node-postgres.com/) | `pg@8.13.0` | `8.11.4` introduced a bug with URL parsing and will not work. `8.11.5` fixes this. Requires `compatibility_flags = ["nodejs_compat"]` and `compatibility_date = "2024-09-23"` - refer to [Node.js compatibility](/workers/runtime-apis/nodejs). Requires wrangler `3.78.7` or later. |
| Drizzle | [https://orm.drizzle.team/](https://orm.drizzle.team/) | `0.26.2`^ | |
| Kysely | [https://kysely.dev/](https://kysely.dev/) | `0.26.3`^ | |
| [rust-postgres](https://github.com/sfackler/rust-postgres) | [https://docs.rs/postgres/latest/postgres/](https://docs.rs/postgres/latest/postgres/) | `v0.19.8` | Use the [`query_typed`](https://docs.rs/postgres/latest/postgres/struct.Client.html#method.query_typed) method for best performance. |
Expand Down Expand Up @@ -97,14 +98,9 @@ Install the `node-postgres` driver:
npm install pg
```

**Ensure you have `compatibility_flags = ["nodejs_compat_v2"]` set in your `wrangler.toml` configuration file**:
**Ensure you have `compatibility_flags` and `compatibility_date` set in your `wrangler.toml` configuration file** as shown below:

```toml
# other fields elided
#
# Required for node-postgres to work
compatibility_flags = ["nodejs_compat_v2"]
```
<Render file="nodejs-compat-wrangler-toml" product="workers" />

Create a new `Client` instance and pass the Hyperdrive parameters:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ This command outputs your Hyperdrive ID. You can now bind your Hyperdrive config
```toml
name = "timescale-api"
main = "src/index.ts"
compatibility_date = "2024-08-21"
compatibility_flags = [ "nodejs_compat_v2"]
compatibility_date = "2024-09-23"
compatibility_flags = [ "nodejs_compat"]

[[hyperdrive]]
binding = "HYPERDRIVE"
Expand Down
12 changes: 12 additions & 0 deletions src/content/partials/workers/nodejs-compat-wrangler-toml.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
{}

---

```toml title="wrangler.toml"
# other fields elided
#
# Required for node-postgres to work
compatibility_flags = [ "nodejs_compat" ]
compatibility_date = "2024-09-23"
```

0 comments on commit cbc4f3d

Please sign in to comment.