Skip to content

Commit 2b674e3

Browse files
committed
Update README
1 parent 80761b5 commit 2b674e3

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ connect: the function to get a connection from the pool
1919
pool: the pool instance
2020
Client: a client constructor for a single query
2121
query: a utility to perform a query _without_ a transaction
22-
transact: a utility to perform a query _with_ a transaction
22+
transact: a utility to perform multiple queries _with_ a transaction
2323
```
2424

2525
Example:
@@ -106,8 +106,9 @@ fastify.register(require('fastify-postgres'), {
106106
})
107107

108108
fastify.post('/user/:username', (req, reply) => {
109-
fastify.pg.transact(
110-
'INSERT INTO users(username) VALUES($1) RETURNING id', [req.params.username],
109+
fastify.pg.transact(async client => {
110+
return client.query('INSERT INTO users(username) VALUES($1) RETURNING id', [req.params.username])
111+
},
111112
function onResult (err, result) {
112113
reply.send(err || result)
113114
}

0 commit comments

Comments
 (0)