Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/57.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
调用mysql模块中不存在的String.config方法(与异步代码相关)_Mysql_Node.js_Async Await - Fatal编程技术网

调用mysql模块中不存在的String.config方法(与异步代码相关)

调用mysql模块中不存在的String.config方法(与异步代码相关),mysql,node.js,async-await,Mysql,Node.js,Async Await,我在项目中遇到一个TypeError:无法读取未定义的属性“typeCast”error。事实证明,这个错误是在mysql模块的代码中的以下代码片段中抛出的(确切位置是node\u modules/mysql/lib/Connection.js:187): 我的代码中的相关片段如下所示: async function mcSeekAllItems(connection) { const sql = 'SELECT * FROM `books`'; return util.prom

我在项目中遇到一个
TypeError:无法读取未定义的属性“typeCast”
error。事实证明,这个错误是在
mysql
模块的代码中的以下代码片段中抛出的(确切位置是
node\u modules/mysql/lib/Connection.js:187
):

我的代码中的相关片段如下所示:

async function mcSeekAllItems(connection) {
    const sql = 'SELECT * FROM `books`';
    return util.promisify(connection.query).call(sql)
        .then(
            results => results
        ).catch(
            error => console.log("Error 006 : ", error)
        );
}
由于我不熟悉
mysql
模块的内部结构,我不确定我在这里做错了什么。 我的节点项目的完整源代码位于

在浏览器中请求
books/
URL会触发此错误。 下面是完整的错误消息:

$ node app.js
Serving on port 3000
Error 006 :  TypeError: Cannot read property 'typeCast' of undefined
    at String.query (/Users/ewandelanoy/Teuliou/Sites/Gwerzher_Leoriou/node_modules/mysql/lib/Connection.js:185:34)
    at internal/util.js:278:30
    at new Promise (<anonymous>)
    at String.query (internal/util.js:277:12)
    at Object.mcSeekAllItems [as seekAllItems] (/Users/ewandelanoy/Teuliou/Sites/Gwerzher_Leoriou/models/book.js:83:45)
    at /Users/ewandelanoy/Teuliou/Sites/Gwerzher_Leoriou/app.js:26:34
    at Layer.handle [as handle_request] (/Users/ewandelanoy/Teuliou/Sites/Gwerzher_Leoriou/node_modules/express/lib/router/layer.js:95:5)
    at next (/Users/ewandelanoy/Teuliou/Sites/Gwerzher_Leoriou/node_modules/express/lib/router/route.js:137:13)
    at Route.dispatch (/Users/ewandelanoy/Teuliou/Sites/Gwerzher_Leoriou/node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (/Users/ewandelanoy/Teuliou/Sites/Gwerzher_Leoriou/node_modules/express/lib/router/layer.js:95:5)
$node app.js
服务于3000端口
错误006:TypeError:无法读取未定义的属性“typeCast”
位于String.query(/Users/ewandelanoy/Teuliou/Sites/Gwerzher\u Leoriou/node\u modules/mysql/lib/Connection.js:185:34)
在internal/util.js:278:30
在新的承诺()
位于String.query(internal/util.js:277:12)
在Object.mcSeekAllItems[作为seekAllItems](/Users/ewandelanoy/Teuliou/Sites/Gwerzher\u Leoriou/models/book.js:83:45)
at/Users/ewandelanoy/Teuliou/Sites/Gwerzher\u Leoriou/app.js:26:34
在Layer.handle[作为handle\u请求](/Users/ewandelanoy/Teuliou/Sites/Gwerzher\u Leoriou/node\u modules/express/lib/router/Layer.js:95:5)
接下来(/Users/ewandelanoy/Teuliou/Sites/Gwerzher\u Leoriou/node\u modules/express/lib/router/route.js:137:13)
在Route.dispatch(/Users/ewandelanoy/Teuliou/Sites/Gwerzher\u Leoriou/node\u modules/express/lib/router/Route.js:112:3)
在Layer.handle[作为handle\u请求](/Users/ewandelanoy/Teuliou/Sites/Gwerzher\u Leoriou/node\u modules/express/lib/router/Layer.js:95:5)
$ node app.js
Serving on port 3000
Error 006 :  TypeError: Cannot read property 'typeCast' of undefined
    at String.query (/Users/ewandelanoy/Teuliou/Sites/Gwerzher_Leoriou/node_modules/mysql/lib/Connection.js:185:34)
    at internal/util.js:278:30
    at new Promise (<anonymous>)
    at String.query (internal/util.js:277:12)
    at Object.mcSeekAllItems [as seekAllItems] (/Users/ewandelanoy/Teuliou/Sites/Gwerzher_Leoriou/models/book.js:83:45)
    at /Users/ewandelanoy/Teuliou/Sites/Gwerzher_Leoriou/app.js:26:34
    at Layer.handle [as handle_request] (/Users/ewandelanoy/Teuliou/Sites/Gwerzher_Leoriou/node_modules/express/lib/router/layer.js:95:5)
    at next (/Users/ewandelanoy/Teuliou/Sites/Gwerzher_Leoriou/node_modules/express/lib/router/route.js:137:13)
    at Route.dispatch (/Users/ewandelanoy/Teuliou/Sites/Gwerzher_Leoriou/node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (/Users/ewandelanoy/Teuliou/Sites/Gwerzher_Leoriou/node_modules/express/lib/router/layer.js:95:5)