I am trying to connect a custom database to auth0 and am using their default Postgres script.
I can't figure out why I am getting the following error:
this._connectionCallback is not a function
connectionCallback doesn't exist in the snippet. Here's the 'verify' snippet:
function verify (email, callback) {
//this example uses the "pg" library
const { Client } = require("pg");
const conString = new
Client({connectionString:'postgresql://postgres:password@database:port/host'});
conString.connect(conString, function (err, client, done) {
if (err) return callback(err);
const query = 'UPDATE auth_user SET email_Verified = true WHERE email_Verified = false AND email = $1';
client.query(query, [email], function (err, result) {
done();
return callback(err, result && result.rowCount > 0);
});
});
}
Appreciate any help with this.
CodePudding user response:
function verify (email, callback) {
//this example uses the "pg" library
const { Client } = require("pg");
const conString = new
Client({connectionString:'postgresql://postgres:password@database:port/host'});
conString.connect(conString, function (err, client, done) {
if (err)
{ console.log(err); return callback(err); }
const query = 'UPDATE auth_user SET email_Verified = true WHERE email_Verified = false AND email = $1';
client.query(query, [email], function (err, result) {
done();
console.log(err);
return callback(err, result && result.rowCount > 0);
});
});
}
for test check this code
CodePudding user response:
I found the solution in this thread - pg.connect not a function?
Basically, pg.connect has been hard-deprecated in favor of pg.Pool, as documented here: https://node-postgres.com/guides/upgrading
So the functional code now looks like this:
function verify (email, callback) {
const bcrypt = require('bcrypt');
const pg = require("pg");
var pool = new pg.Pool({
user: '**',
host: '**',
database: '**',
password: '**',
port: **,
});
pool.connect(function (err, client, done) {
if (err)
console.log('error');
{ console.log(err); return callback(err); }
const query = 'UPDATE auth_user SET email_Verified = true WHERE email_Verified = false AND email = $1';
client.query(query, [email], function (err, result) {
done();
console.log(err);
return callback(err, result && result.rowCount > 0);
});
});
}