PG Pool connect using `await` error : Unexpected identifier
See original GitHub issueAccording to doc https://node-postgres.com/features/connecting
const Koa = require('koa')
const app = new Koa()
const { Pool } = require('pg')
const pool = new Pool({connectionString:"postgresql://shawn:passwordxxxxxx@localhost:5432/dbname"})
const res = await pool.query('SELECT NOW()')
await pool.end()
await client.end()
app.use(async ctx => {
ctx.body = 'Hello World';
});
app.listen(3000);
Error Log
Debugging with inspector protocol because Node.js v8.6.0 was detected.
node --inspect-brk=25673 BE/app.js
Debugger listening on ws://127.0.0.1:25673/60ee7dd1-9214-474b-b475-5f1e1a660e87
Debugger attached.
/Users/shawn/todayinhistory/BE/app.js:9
const res = await pool.query('SELECT NOW()')
^^^^
SyntaxError: Unexpected identifier
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:588:28)
at Object.Module._extensions..js (module.js:635:10)
at Module.load (module.js:545:32)
at tryModuleLoad (module.js:508:12)
at Function.Module._load (module.js:500:3)
at Function.Module.runMain (module.js:665:10)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:607:3
Waiting for the debugger to disconnect...
SyntaxError: Unexpected identifier
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:588:28)
at Object.Module._extensions..js (module.js:635:10)
at Module.load (module.js:545:32)
at tryModuleLoad (module.js:508:12)
at Function.Module._load (module.js:500:3)
at Function.Module.runMain (module.js:665:10)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:607:3
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
await with pg throws an error - node.js - Stack Overflow
The node.js complains with the error: await pool.connect() ^^^^ SyntaxError: Unexpected identifier at ...
Read more >node-mssql | Microsoft SQL Server client for Node.js
An important concept to understand when using this library is Connection Pooling as this library uses connection pooling extensively. As one Node JS...
Read more >Node.js with MySQL - w3resource
Pooling connections, options and events; Escaping query values, identifiers; Preparing Queries; Stored procedures; Joins; Transactions; Timeouts ...
Read more >Pooling – node-postgres
node-postgres ships with built-in connection pooling via the pg-pool module. ... pool.on('error', (err, client) => { console.error('Unexpected error on idle ...
Read more >Reactive PostgreSQL Client - Eclipse Vert.x
Most of the time you will use a pool to connect to PostgreSQL: ... SqlClient client = PgPool.client(vertx, connectOptions, poolOptions); // Pipelined ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
So the doc is outdated !
Hi all, this is still an issue (Outdated docs) - as someone picking up postgress tonight and trying to follow along with the docs, I’m still left scratching my head here.