![](/img/trans.png)
[英]I'm getting an error for an unrecognized function within Auth0's node package, specifically in their AuthenticationClient and ManagementClient API
[英]Auth0 Postgresql getting error - this._connectionCallback is not a function
我正在尝试将自定义数据库连接到 auth0 并使用他们的默认 Postgres 脚本。
我不明白为什么会出现以下错误:
this._connectionCallback 不是 function
片段中不存在 connectionCallback。 这是“验证”片段:
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);
});
});
}
感谢对此的任何帮助。
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); }); }); }
测试检查此代码
我在这个线程中找到了解决方案 - pg.connect 不是 function?
基本上,pg.connect 已被硬弃用,取而代之的是 pg.Pool,如此处记录: https://node-postgres.com/guides/upgrading
所以功能代码现在看起来像这样:
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);
});
});
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.