mirror of
https://github.com/brianc/node-postgres.git
synced 2025-12-08 20:16:25 +00:00
Update docs with logo & info on pooling
This commit is contained in:
parent
53901a1d59
commit
3086b6646e
11
docs/components/logo.tsx
Normal file
11
docs/components/logo.tsx
Normal file
@ -0,0 +1,11 @@
|
||||
import React from 'react'
|
||||
|
||||
type Props = {
|
||||
src: string
|
||||
alt?: string
|
||||
}
|
||||
|
||||
export function Logo(props: Props) {
|
||||
const alt = props.alt || 'Logo'
|
||||
return <img src={props.src} alt={alt} width={100} height={100} style={{ width: 400, height: 'auto' }} />
|
||||
}
|
||||
@ -3,6 +3,8 @@ title: Welcome
|
||||
slug: /
|
||||
---
|
||||
|
||||
import { Logo } from '/components/logo.tsx'
|
||||
|
||||
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.
|
||||
|
||||
## Install
|
||||
@ -15,6 +17,21 @@ $ npm install pg
|
||||
|
||||
node-postgres continued development and support is made possible by the many [supporters](https://github.com/brianc/node-postgres/blob/master/SPONSORS.md).
|
||||
|
||||
Special thanks to [Medplum](https://www.medplum.com/) for sponsoring node-postgres for a whole year!
|
||||
|
||||
<a href="https://www.medplum.com/">
|
||||
<img
|
||||
alt="Medplum"
|
||||
src="https://raw.githubusercontent.com/medplum/medplum-logo/refs/heads/main/medplum-logo.png"
|
||||
style={{
|
||||
width: '300px',
|
||||
height: 'auto',
|
||||
margin: '0 auto',
|
||||
display: 'block',
|
||||
}}
|
||||
/>
|
||||
</a>
|
||||
|
||||
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!
|
||||
|
||||
# Version compatibility
|
||||
@ -54,21 +71,17 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
### Callbacks
|
||||
### Pooling
|
||||
|
||||
If you prefer a callback-style approach to asynchronous programming, all async methods support an optional callback parameter as well:
|
||||
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:
|
||||
|
||||
```js
|
||||
import { Client } from 'pg'
|
||||
const client = new Client()
|
||||
|
||||
client.connect((err) => {
|
||||
client.query('SELECT $1::text as message', ['Hello world!'], (err, res) => {
|
||||
console.log(err ? err.stack : res.rows[0].message) // Hello World!
|
||||
client.end()
|
||||
})
|
||||
})
|
||||
|
||||
import { Pool } from 'pg'
|
||||
const pool = new Pool()
|
||||
const res = await pool.query('SELECT $1::text as message', ['Hello world!'])
|
||||
console.log(res.rows[0].message) // Hello world!
|
||||
```
|
||||
|
||||
Our real-world apps are almost always more complicated than that, and I urge you to read on!
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user