它说无法读取属性authorid
未定义在socket.broadcast行。Mysql-nodejs嵌套查询
setInterval(function(){
db.query("select * from `notifications`", function(err, rows){
if (rows.length>temp){
for (var i=temp; i<rows.length; i++){
console.log('sending room post', rows[i].authorid);
db.query("select `name` from `users` where `id`=?", [rows[i].authorid ], function(err, name){
name=name[0].name;
socket.broadcast.to(rows[i].authorid).emit('new notification', {
authorname:name,
dpid:rows[i].followid,
read:rows[i].read,
type:rows[i].type,
followstatus:1
});
});
}
temp=rows.length;
}
})
}, 3000);
什么的的console.log输出? – satchcoder 2015-02-07 17:52:14