Here's my code containing PostgreSql query using pg-promise:
var db = require('/pg-connection'),
PQ = require('pg-promise').ParameterizedQuery;
var fullname = 'username',
email = 'UniqueEmailHere',
password = 'userPassword',
uuid = '15-20charactersRandomString';
var query = new PQ("INSERT INTO tablename.user (fullname, email, password, uuid, status)
VALUES($1, $2, $3, $4, $5) RETURNING id",
[fullname, email, password, uuid, '1' ] );
db.any(query)
.then(function (data) {
callback(null, data)
})
.catch(function (err) {
console.log(err)
callback(err)
});
Query inserts the values (as given) into the database but at the same returns the error
in catch:
[ReferenceError: uuid not defined]
I tried running the same query in pgAdmin4 and its running fine there as well. Can somebody please point out what's the real issue?