节点js mysql访问javascript对象
我在Node.JS中查询一个db,我试图访问CodeFile中FileContent字段的内容,它返回一个Javascript对象:result节点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
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)