Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/458.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/59.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
节点js mysql访问javascript对象_Javascript_Mysql_Node.js - Fatal编程技术网

节点js mysql访问javascript对象

节点js mysql访问javascript对象,javascript,mysql,node.js,Javascript,Mysql,Node.js,我在Node.JS中查询一个db,我试图访问CodeFile中FileContent字段的内容,它返回一个Javascript对象:result jsUpdateCon.query('SELECT FileContent FROM codeFile WHERE ID = ?',[msg[1]], function(err, result){ if (err) throw err; console.log('Data received from DB:\n'); console.log(r

我在Node.JS中查询一个db,我试图访问CodeFile中FileContent字段的内容,它返回一个Javascript对象:result

jsUpdateCon.query('SELECT FileContent FROM codeFile WHERE ID = ?',[msg[1]], function(err, result){
if (err) throw err;
console.log('Data received from DB:\n');
    console.log(result);
});
控制台输出:
[RowDataPacket{FileContent:'someContent'}]

如果我尝试
console.log(result.RowDataPacket)我明白了

控制台输出:
未定义

如果我尝试
console.log(result.RowDataPacket.FileContent)

整个节点崩溃

TypeError:无法读取未定义的属性“FileContent”

我的最终目标是

控制台输出:
someContent
在使用console.log(result.something.something)时


我做错了什么?

看起来
结果是一个数组,请尝试这样访问它:

console.log(result[0].FileContent)