Skip to content

Commit 3086b66

Browse files
author
Brian Carlson
committed
Update docs with logo & info on pooling
1 parent 53901a1 commit 3086b66

2 files changed

Lines changed: 36 additions & 12 deletions

File tree

docs/components/logo.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import React from 'react'
2+
3+
type Props = {
4+
src: string
5+
alt?: string
6+
}
7+
8+
export function Logo(props: Props) {
9+
const alt = props.alt || 'Logo'
10+
return <img src={props.src} alt={alt} width={100} height={100} style={{ width: 400, height: 'auto' }} />
11+
}

docs/pages/index.mdx

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ title: Welcome
33
slug: /
44
---
55

6+
import { Logo } from '/components/logo.tsx'
7+
68
node-postgres is a collection of node.js modules for interfacing with your PostgreSQL database. It has support for callbacks, promises, async/await, connection pooling, prepared statements, cursors, streaming results, C/C++ bindings, rich type parsing, and more! Just like PostgreSQL itself there are a lot of features: this documentation aims to get you up and running quickly and in the right direction. It also tries to provide guides for more advanced & edge-case topics allowing you to tap into the full power of PostgreSQL from node.js.
79

810
## Install
@@ -15,6 +17,21 @@ $ npm install pg
1517

1618
node-postgres continued development and support is made possible by the many [supporters](https://github.com/brianc/node-postgres/blob/master/SPONSORS.md).
1719

20+
Special thanks to [Medplum](https://www.medplum.com/) for sponsoring node-postgres for a whole year!
21+
22+
<a href="https://www.medplum.com/">
23+
<img
24+
alt="Medplum"
25+
src="https://raw.githubusercontent.com/medplum/medplum-logo/refs/heads/main/medplum-logo.png"
26+
style={{
27+
width: '300px',
28+
height: 'auto',
29+
margin: '0 auto',
30+
display: 'block',
31+
}}
32+
/>
33+
</a>
34+
1835
If you or your company would like to sponsor node-postgres stop by [GitHub Sponsors](https://github.com/sponsors/brianc) and sign up or feel free to [email me](mailto:brian@pecanware.com) if you want to add your logo to the documentation or discuss higher tiers of sponsorship!
1936

2037
# Version compatibility
@@ -54,21 +71,17 @@ try {
5471
}
5572
```
5673

57-
### Callbacks
74+
### Pooling
5875

59-
If you prefer a callback-style approach to asynchronous programming, all async methods support an optional callback parameter as well:
76+
In most applications you'll wannt to use a [connection pool](/features/pooling) to manage your connections. This is a more advanced topic, but here's a simple example of how to use it:
6077

6178
```js
62-
import { Client } from 'pg'
63-
const client = new Client()
64-
65-
client.connect((err) => {
66-
client.query('SELECT $1::text as message', ['Hello world!'], (err, res) => {
67-
console.log(err ? err.stack : res.rows[0].message) // Hello World!
68-
client.end()
69-
})
70-
})
71-
79+
import { Pool } from 'pg'
80+
const pool = new Pool()
81+
const res = await pool.query('SELECT $1::text as message', ['Hello world!'])
82+
console.log(res.rows[0].message) // Hello world!
7283
```
7384

7485
Our real-world apps are almost always more complicated than that, and I urge you to read on!
86+
87+

0 commit comments

Comments
 (0)