Here's my code, it's pretty much straight out of the docs:
var pg = require('pg');
var client = new pg.Client('postgres://localhost');
client.connect();
var dbName ='myDb';
var query = client.query('CREATE DATABASE $1', [dbName]);
query.on('error', console.log.bind(console));
Unfortunately, it fails:
{ [error: syntax error at or near "$1"]
name: 'error',
length: 84,
severity: 'ERROR',
code: '42601',
detail: undefined,
hint: undefined,
position: '17',
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
file: 'scan.l',
line: '1006',
routine: 'scanner_yyerror' }
It works without the use of the parameter. Does anyone know why?