this._callback.apply 不是函数!节点 js Mysql 错误 [英] this._callback.apply is not a function ! Node js Mysql error
问题描述
控制器代码
app.post('/savedata', function(req, res) {
var cope = req.body;
console.log("On server side");
console.log(cope.Client_ID);
var queries =
connection.query('update lv_billing.client SET Client_ID = ?, Client_Name = ?,Status = ?,Updt_Time = ?,Updt_By = ?,Updt_ID = ?,Cluster = ? where Client_ID = ?',cope.Client_ID,cope.Client_Name,cope.Status,cope.Updt_Time,cope.Updt_By,cope.Updt_ID,cope.Cluster,cope.Client_ID, function(err,res){
if(err) throw err;
console.log('Inserted!');
})
});
上面的代码抛出错误this._callback.apply"甚至不是一个函数.设置一个小上下文.我正在尝试使用数组中的新值更新我的表.'cope' 是一个数组,其中包含需要更新的值.
The above code is throwing the error "this._callback.apply" is not even a function. To set a little context. i m trying to update my table with the new values from the array. 'cope' is an array which holds values which needs to be updated.
推荐答案
正如@RugDealer 提到的,您应该提供回调函数作为第二个或第三个参数.如果你正在使用 mysql 模块,你可以像这样改变你的函数:
As @RugDealer mentioned, you should provide the callback function as the second or third argument. If you are using the mysql module you can alter your function like this:
app.post('/savedata', function(req, res) {
var cope = req.body;
console.log("On server side");
console.log(cope.Client_ID);
var params = [cope.Client_ID, cope.Client_Name, cope.Status, cope.Updt_Time, cope.Updt_By, cope.Updt_ID, cope.Cluster, cope.Client_ID];
var queries =
connection.query('update lv_billing.client SET Client_ID = ?,Client_Name = ?,Status = ?,Updt_Time = ?,Updt_By = ?,Updt_ID = ?,Cluster = ? where Client_ID = ?',params, function(err,res){
if(err) throw err;
console.log('Inserted!');
});
});
有关更多信息,请查看源:https://www.npmjs.com/package/mysql一个>
For more information checkout the source: https://www.npmjs.com/package/mysql
这篇关于this._callback.apply 不是函数!节点 js Mysql 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!