1
- # Postgres.js
1
+
2
+
3
+ <img align =" left " width =" 460 " height =" 124 " alt =" Fastest full PostgreSQL nodejs client " src =" postgresjs.svg " />
4
+
2
5
3
6
- 🚀 Fastest full featured PostgreSQL client for Node.js
4
7
- 🚯 1300 LOC - 0 dependencies
7
10
8
11
## Getting started
9
12
13
+ <br >
14
+ <img height =" 220 " alt =" Good UX with Postgres.js " src =" demo.gif " />
15
+ <br >
16
+
10
17
** Install**
11
18
``` bash
12
19
$ npm install postgres
@@ -15,7 +22,7 @@ $ npm install postgres
15
22
** Use**
16
23
``` js
17
24
18
- import postgres from ' postgres'
25
+ const postgres = require ( ' postgres' )
19
26
20
27
const sql = postgres ({ ... options }) // will default to the same as psql
21
28
@@ -27,13 +34,6 @@ const something = await sql`
27
34
28
35
```
29
36
30
- ** Node pre 13.1.0**
31
- ``` js
32
-
33
- const postgres = require (' postgres/cjs' )
34
-
35
- ```
36
-
37
37
## Connection options
38
38
39
39
You can use either a postgres:// url connection string or the options to define your database connection properties.
@@ -44,9 +44,9 @@ const sql = postgres('postgres://user:pass@host:port/database', {
44
44
host : ' ' , // or hostname
45
45
port : 5432 , // Postgres server port
46
46
path : ' ' , // unix socket path (usually '/tmp')
47
- database : ' ' , // Database to connect to
48
- username : ' ' , // or username
49
- password : ' ' , // or password
47
+ database : ' ' , // or db
48
+ username : ' ' , // or user
49
+ password : ' ' , // or pass
50
50
ssl : false , // True, or options for tls.connect
51
51
max : 10 , // Max number of connections
52
52
timeout : 0 , // Idle connection timeout in seconds
0 commit comments