mirror of
https://github.com/brianc/node-postgres.git
synced 2026-02-01 16:47:23 +00:00
docs: code style consistency
This commit is contained in:
parent
57e93b5daf
commit
a158f035dc
@ -44,7 +44,7 @@ The simplest possible way to connect, query, and disconnect is with async/await:
|
||||
|
||||
```js
|
||||
import { Client } from 'pg'
|
||||
const client = await new Client().connect();
|
||||
const client = await new Client().connect()
|
||||
|
||||
const res = await client.query('SELECT $1::text as message', ['Hello world!'])
|
||||
console.log(res.rows[0].message) // Hello world!
|
||||
@ -55,10 +55,9 @@ await client.end()
|
||||
|
||||
For the sake of simplicity, these docs will assume that the methods are successful. In real life use, make sure to properly handle errors thrown in the methods. A `try/catch` block is a great way to do so:
|
||||
|
||||
```ts
|
||||
```js
|
||||
import { Client } from 'pg'
|
||||
const client = new Client()
|
||||
await client.connect()
|
||||
const client = await new Client().connect()
|
||||
|
||||
try {
|
||||
const res = await client.query('SELECT $1::text as message', ['Hello world!'])
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user