Skip to content

Commit d6b61d5

Browse files
committed
postgres connect update
1 parent 1b3b699 commit d6b61d5

File tree

6 files changed

+45
-51
lines changed

6 files changed

+45
-51
lines changed

src/content/documentation/docs/connect-neon.mdx

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,26 +37,26 @@ drizzle-orm @neondatabase/serverless
3737
#### Step 2 - Initialize the driver and make a query
3838
<CodeTabs items={["Neon HTTP", "Neon Websockets", "node-postgres", "postgres.js"]}>
3939
```typescript
40-
import { drizzle } from 'drizzle-orm/connect';
40+
import { drizzle } from 'drizzle-orm/neon-http';
4141

42-
const db = await drizzle("neon-http", process.env.DATABASE_URL);
42+
const db = drizzle(process.env.DATABASE_URL);
4343

4444
const result = await db.execute('select 1');
4545
```
4646
<Section>
4747
```typescript
48-
import { drizzle } from 'drizzle-orm/connect';
48+
import { drizzle } from 'drizzle-orm/neon-serverless';
4949

50-
const db = await drizzle("neon-websockets", process.env.DATABASE_URL);
50+
const db = drizzle(process.env.DATABASE_URL);
5151

5252
const result = await db.execute('select 1');
5353
```
5454
```typescript
5555
// For Node.js - make sure to install the 'ws' and 'bufferutil' packages
56-
import { drizzle } from 'drizzle-orm/connect';
56+
import { drizzle } from 'drizzle-orm/neon-serverless';
5757
import ws from 'ws';
5858

59-
const db = await drizzle("neon-websockets", {
59+
const db = drizzle({
6060
connection: process.env.DATABASE_URL,
6161
ws: ws,
6262
});
@@ -70,32 +70,31 @@ Add the `ws` and `bufferutil` packages to your project's dependencies, and set `
7070
</Section>
7171
```typescript
7272
// Make sure to install the 'pg' package
73-
import { drizzle } from 'drizzle-orm/connect';
73+
import { drizzle } from 'drizzle-orm/node-postgres';
7474

75-
const db = await drizzle("node-postgres", process.env.DATABASE_URL);
75+
const db = drizzle(process.env.DATABASE_URL);
7676

7777
const result = await db.execute('select 1');
7878
```
7979
```typescript
8080
// Make sure to install the 'postgres' package
81-
import { drizzle } from 'drizzle-orm/connect';
81+
import { drizzle } from 'drizzle-orm/postgres-js';
8282

83-
const db = await drizzle("postgres-js", process.env.DATABASE_URL);
83+
const db = drizzle(process.env.DATABASE_URL);
8484

8585
const result = await db.execute('select 1');
8686
```
8787
</CodeTabs>
8888

89-
If you need a synchronous connection, you can use our additional connection API,
90-
where you specify a driver connection and pass it to the Drizzle instance.
89+
If you need to provide your existing drivers:
9190

9291
<CodeTabs items={["Neon HTTP", "Neon Websockets", "node-postgres", "postgres.js"]}>
9392
```typescript
9493
import { neon } from '@neondatabase/serverless';
9594
import { drizzle } from 'drizzle-orm/neon-http';
9695

9796
const sql = neon(process.env.DATABASE_URL!);
98-
const db = drizzle(sql);
97+
const db = drizzle({ client: sql });
9998

10099
const result = await db.execute('select 1');
101100
```
@@ -105,7 +104,7 @@ import { Pool } from '@neondatabase/serverless';
105104
import { drizzle } from 'drizzle-orm/neon-serverless';
106105

107106
const pool = new Pool({ connectionString: process.env.DATABASE_URL });
108-
const db = drizzle(pool)
107+
const db = drizzle({ client: pool })
109108

110109
const result = await db.execute('select 1');
111110
```
@@ -117,7 +116,7 @@ import { drizzle } from 'drizzle-orm/neon-serverless';
117116
neonConfig.webSocketConstructor = ws;
118117

119118
const pool = new Pool({ connectionString: process.env.DATABASE_URL });
120-
const db = drizzle(pool)
119+
const db = drizzle({ client: pool })
121120

122121
const result = await db.execute('select 1');
123122
```
@@ -135,7 +134,7 @@ import { Pool } from "pg";
135134
const pool = new Pool({
136135
connectionString: process.env.DATABASE_URL,
137136
});
138-
const db = drizzle(pool);
137+
const db = drizzle({ client: pool });
139138

140139
const result = await db.execute('select 1');
141140
```
@@ -145,7 +144,7 @@ import { drizzle } from 'drizzle-orm/postgres-js';
145144
import postgres from 'postgres';
146145

147146
const queryClient = postgres(process.env.DATABASE_URL);
148-
const db = drizzle(queryClient);
147+
const db = drizzle({ client: queryClient });
149148

150149
const result = await db.execute('select 1');
151150
```

src/content/documentation/docs/connect-pglite.mdx

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,39 +32,38 @@ drizzle-orm @electric-sql/pglite
3232
#### Step 2 - Initialize the driver and make a query
3333
<CodeTabs items={["In-Memory", "In directory", "With extra config options"]}>
3434
```typescript copy"
35-
import { drizzle } from 'drizzle-orm/connect';
35+
import { drizzle } from 'drizzle-orm/pglite';
3636

37-
const db = drizzle('pglite');
37+
const db = drizzle();
3838

3939
await db.select().from(...);
4040
```
4141
```typescript copy"
42-
import { drizzle } from 'drizzle-orm/connect';
42+
import { drizzle } from 'drizzle-orm/pglite';
4343

44-
const db = drizzle('pglite', 'path-to-dir');
44+
const db = drizzle('path-to-dir');
4545

4646
await db.select().from(...);
4747
```
4848
```typescript copy"
49-
import { drizzle } from 'drizzle-orm/connect';
49+
import { drizzle } from 'drizzle-orm/pglite';
5050

5151
// connection is a native PGLite configuration
52-
const db = drizzle('pglite', { connection: { dataDir: 'path-to-dir' }});
52+
const db = drizzle({ connection: { dataDir: 'path-to-dir' }});
5353

5454
await db.select().from(...);
5555
```
5656
</CodeTabs>
5757

58-
If you need a synchronous connection, you can use our additional connection API,
59-
where you specify a driver connection and pass it to the Drizzle instance.
58+
If you need to provide your existing driver:
6059

6160
```typescript copy"
6261
import { PGlite } from '@electric-sql/pglite';
6362
import { drizzle } from 'drizzle-orm/pglite';
6463

6564
// In-memory Postgres
6665
const client = new PGlite();
67-
const db = drizzle(client);
66+
const db = drizzle({ client });
6867

6968
await db.select().from(users);
7069
```

src/content/documentation/docs/connect-supabase.mdx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,20 @@ drizzle-orm postgres
2828
#### Step 2 - Initialize the driver and make a query
2929

3030
```typescript copy filename="index.ts"
31-
import { drizzle } from 'drizzle-orm'
31+
import { drizzle } from 'drizzle-orm/postgres-js'
3232

33-
const db = drizzle('postgres-js', process.env.DATABASE_URL);
33+
const db = drizzle(process.env.DATABASE_URL);
3434

3535
const allUsers = await db.select().from(...);
3636
```
37-
If you need a synchronous connection, you can use our additional connection API,
38-
where you specify a driver connection and pass it to the Drizzle instance.
3937

38+
If you need to provide your existing driver:
4039
```typescript copy filename="index.ts"
4140
import { drizzle } from 'drizzle-orm/postgres-js'
4241
import postgres from 'postgres'
4342

4443
const client = postgres(process.env.DATABASE_URL)
45-
const db = drizzle(client);
44+
const db = drizzle({ client });
4645

4746
const allUsers = await db.select().from(...);
4847
```
@@ -55,7 +54,7 @@ import postgres from 'postgres'
5554

5655
// Disable prefetch as it is not supported for "Transaction" pool mode
5756
const client = postgres(process.env.DATABASE_URL, { prepare: false })
58-
const db = drizzle(client);
57+
const db = drizzle({ client });
5958

6059
const allUsers = await db.select().from(...);
6160
```

src/content/documentation/docs/connect-tidb.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ drizzle-orm @tidbcloud/serverless
3535
```typescript copy filename="index.ts"
3636
import { drizzle } from 'drizzle-orm/tidb-serverless';
3737

38-
const db = await drizzle({ connection: { url: process.env.TIDB_URL }});
38+
const db = drizzle({ connection: { url: process.env.TIDB_URL }});
3939

4040
const response = await db.select().from(...)
4141
```

src/content/documentation/docs/connect-vercel-postgres.mdx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,14 @@ Setup a project according to the **[official docs.](https://vercel.com/docs/stor
3939
#### Step 3 - Initialize the driver and make a query
4040

4141
```typescript copy
42-
import { drizzle } from 'drizzle-orm/connect';
42+
import { drizzle } from 'drizzle-orm/vercel-postgres';
4343

44-
const db = await drizzle("vercel-postgres");
44+
const db = drizzle();
4545

4646
const result = await db.execute('select 1');
4747
```
4848

49-
If you need a synchronous connection, you can use our additional connection API,
50-
where you specify a driver connection and pass it to the Drizzle instance.
49+
If you need to provide your existing driver:
5150

5251
```typescript copy
5352
import { sql } from '@vercel/postgres';

src/content/documentation/docs/get-started-postgresql.mdx

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,18 @@ drizzle-orm pg
3535
<CodeTabs items={["node-postgres", "node-postgres with config"]}>
3636
```typescript copy
3737
// Make sure to install the 'pg' package
38-
import { drizzle } from 'drizzle-orm/connect';
38+
import { drizzle } from 'drizzle-orm/node-postgres';
3939

40-
const db = await drizzle("node-postgres", process.env.DATABASE_URL);
40+
const db = drizzle(process.env.DATABASE_URL);
4141

4242
const result = await db.execute('select 1');
4343
```
4444
```typescript copy
4545
// Make sure to install the 'pg' package
46-
import { drizzle } from 'drizzle-orm/connect';
46+
import { drizzle } from 'drizzle-orm/node-postgres';
4747

4848
// You can specify any property from the node-postgres connection options
49-
const db = await drizzle("node-postgres", {
49+
const db = drizzle({
5050
connection: {
5151
connectionString: process.env.DATABASE_URL,
5252
ssl: true
@@ -57,8 +57,7 @@ const result = await db.execute('select 1');
5757
```
5858
</CodeTabs>
5959

60-
If you need a synchronous connection, you can use our additional connection API,
61-
where you specify a driver connection and pass it to the Drizzle instance.
60+
If you need to provide your existing driver:
6261

6362
```typescript copy
6463
// Make sure to install the 'pg' package
@@ -69,7 +68,7 @@ import { Pool } from "pg";
6968
const pool = new Pool({
7069
connectionString: process.env.DATABASE_URL,
7170
});
72-
const db = drizzle(pool);
71+
const db = drizzle({ client: pool });
7372

7473
const result = await db.execute('select 1');
7574
```
@@ -84,17 +83,17 @@ drizzle-orm postgres
8483
#### Step 2 - Initialize the driver and make a query
8584
<CodeTabs items={["postgres.js", "postgres.js with config"]}>
8685
```typescript copy
87-
import { drizzle } from 'drizzle-orm/connect';
86+
import { drizzle } from 'drizzle-orm/postgres-js';
8887

89-
const db = await drizzle("postgres-js", process.env.DATABASE_URL);
88+
const db = drizzle(process.env.DATABASE_URL);
9089

9190
const result = await db.execute('select 1');
9291
```
9392
```typescript copy
94-
import { drizzle } from 'drizzle-orm/connect';
93+
import { drizzle } from 'drizzle-orm/postgres-js';
9594

9695
// You can specify any property from the postgres-js connection options
97-
const db = await drizzle("postgres-js", {
96+
const db = drizzle({
9897
connection: {
9998
url: process.env.DATABASE_URL,
10099
ssl: true
@@ -105,16 +104,15 @@ const result = await db.execute('select 1');
105104
```
106105
</CodeTabs>
107106

108-
If you need a synchronous connection, you can use our additional connection API,
109-
where you specify a driver connection and pass it to the Drizzle instance.
107+
If you need to provide your existing driver:
110108

111109
```typescript copy
112110
// Make sure to install the 'postgres' package
113111
import { drizzle } from 'drizzle-orm/postgres-js';
114112
import postgres from 'postgres';
115113

116114
const queryClient = postgres(process.env.DATABASE_URL);
117-
const db = drizzle(queryClient);
115+
const db = drizzle({ client: queryClient });
118116

119117
const result = await db.execute('select 1');
120118
```

0 commit comments

Comments
 (0)