Skip to content

Commit fb0b248

Browse files
committed
pg
1 parent d6b61d5 commit fb0b248

File tree

2 files changed

+23
-47
lines changed

2 files changed

+23
-47
lines changed

src/components/markdown/get-started/postgresql/ConnectNeon.mdx

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,18 @@ import Section from "@mdx/Section.astro";
55
Create a `index.ts` file in the `src/db` directory and initialize the connection:
66

77
```typescript
8-
import { drizzle } from 'drizzle-orm/connect';
9-
10-
async function main() {
11-
const db = await drizzle("neon-http", process.env.DATABASE_URL);
12-
}
8+
import { drizzle } from 'drizzle-orm/neon-http';
139

14-
main();
10+
const db = await drizzle("neon-http", process.env.DATABASE_URL);
1511
```
1612

1713
If you need a synchronous connection, you can use our additional connection API,
1814
where you specify a driver connection and pass it to the Drizzle instance.
1915

2016
```typescript
2117
import { neon } from '@neondatabase/serverless';
22-
import { drizzle } from 'drizzle-orm/neon-http';
23-
24-
async function main() {
25-
const sql = neon(process.env.DATABASE_URL!);
26-
const db = drizzle(sql);
27-
}
18+
import { drizzle } from 'drizzle-orm/neon-serverless';
2819

29-
main();
20+
const sql = neon(process.env.DATABASE_URL!);
21+
const db = drizzle(sql);
3022
```

src/components/markdown/get-started/postgresql/ConnectPostgreSQL.mdx

Lines changed: 18 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,50 +2,34 @@ import CodeTabs from "@mdx/CodeTabs.astro";
22

33
Create a `index.ts` file in the `src/db` directory and initialize the connection:
44

5-
<CodeTabs items={["node-postgres", "node-postgres with config"]}>
5+
<CodeTabs items={["node-postgres", "node-postgres with config", "your node-postgres driver"]}>
66
```typescript copy
77
import 'dotenv/config';
8-
import { drizzle } from 'drizzle-orm/connect';
8+
import { drizzle } from 'drizzle-orm/node-postgres';
99

10-
async function main() {
11-
const db = await drizzle("node-postgres", process.env.DATABASE_URL!);
12-
}
13-
14-
main();
10+
const db = drizzle(process.env.DATABASE_URL!);
1511
```
1612
```typescript copy
1713
import 'dotenv/config';
18-
import { drizzle } from 'drizzle-orm/connect';
19-
20-
async function main() {
21-
// You can specify any property from the node-postgres connection options
22-
const db = await drizzle("node-postgres", {
23-
connection: {
24-
connectionString: process.env.DATABASE_URL!,
25-
ssl: true
26-
}
27-
});
28-
}
29-
30-
main();
14+
import { drizzle } from 'drizzle-orm/node-postgres';
15+
16+
// You can specify any property from the node-postgres connection options
17+
const db = await drizzle("node-postgres", {
18+
connection: {
19+
connectionString: process.env.DATABASE_URL!,
20+
ssl: true
21+
}
22+
});
3123
```
32-
</CodeTabs>
33-
34-
If you need a synchronous connection, you can use our additional connection API,
35-
where you specify a driver connection and pass it to the Drizzle instance.
36-
3724
```typescript copy
3825
import 'dotenv/config';
3926
import { pgTable, serial, text, varchar } from "drizzle-orm/pg-core";
4027
import { drizzle } from "drizzle-orm/node-postgres";
4128
import { Pool } from "pg";
4229

43-
async function main() {
44-
const pool = new Pool({
45-
connectionString: process.env.DATABASE_URL!,
46-
});
47-
const db = drizzle(pool);
48-
}
49-
50-
main();
51-
```
30+
const pool = new Pool({
31+
connectionString: process.env.DATABASE_URL!,
32+
});
33+
const db = drizzle(pool);
34+
```
35+
</CodeTabs>

0 commit comments

Comments
 (0)