We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4f43a1d commit e83e2c4Copy full SHA for e83e2c4
README.md
@@ -106,13 +106,10 @@ fastify.register(require('fastify-postgres'), {
106
})
107
108
fastify.post('/user/:username', (req, reply) => {
109
- fastify.pg.transact(async client => {
110
- try {
111
- const id = await client.query('INSERT INTO users(username) VALUES($1) RETURNING id', [req.params.username])
112
- reply.send(id)
113
- } catch (err) {
114
- reply.send(err)
115
- }
+ // will return a promise
+ return fastify.pg.transact(async client => {
+ // will resolve to an id, or reject with an error
+ return await client.query('INSERT INTO users(username) VALUES($1) RETURNING id', [req.params.username])
116
117
118
0 commit comments