@@ -2,50 +2,34 @@ import CodeTabs from "@mdx/CodeTabs.astro";
2
2
3
3
Create a ` index.ts ` file in the ` src/db ` directory and initialize the connection:
4
4
5
- <CodeTabs items = { [" node-postgres" , " node-postgres with config" ]} >
5
+ <CodeTabs items = { [" node-postgres" , " node-postgres with config" , " your node-postgres driver " ]} >
6
6
``` typescript copy
7
7
import ' dotenv/config' ;
8
- import { drizzle } from ' drizzle-orm/connect ' ;
8
+ import { drizzle } from ' drizzle-orm/node-postgres ' ;
9
9
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 ! );
15
11
```
16
12
``` typescript copy
17
13
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
+ });
31
23
```
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
-
37
24
``` typescript copy
38
25
import ' dotenv/config' ;
39
26
import { pgTable , serial , text , varchar } from " drizzle-orm/pg-core" ;
40
27
import { drizzle } from " drizzle-orm/node-postgres" ;
41
28
import { Pool } from " pg" ;
42
29
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