client.query("select * from rooms where token = ?", [data.token], function(err, results, fields) {
callback(results);
console.log(results);
});
这是一个以数组形式返回结果的查询。我如何获得必要的字段?
答案 0 :(得分:0)
查看您的评论,如果json对象是 - :
[
{
"bump":"1376149484",
"user":"alex",
"token":"11569",
"active":0
}
]
您可以像这样迭代对象 -
for (var i in results)
{
console.log('bump = ' + results[i].bump);
console.log('user = ' + results[i].user);
console.log('token = ' + results[i].token);
console.log('active = ' + results[i].active);
}