【发布时间】:2014-03-21 19:25:08
【问题描述】:
我在 node.js 和 socket.io 工作,基本上我侦听一个套接字 disconnect 事件并调用一个方法。 app.update()
socket.on('disconnect', function (data) {
app.update();
});
// This is in another file, and the id is static, but I am more concered with the
// messages object that is passed through.
update: function() {
models.Message.find({_id: "532c8d9ce889ed4c21538630"}, function(err, messages) {
console.log(messages)
});
}
这就是messages 对象的样子
[ { username: 'Marcus',
connected: true,
_id: 532c8d9ce889ed4c21538630,
__v: 0 } ]
我不确定如何访问带有括号的对象,但基本上我想更新该对象,以便将connected 设置为 false。
我试过messages['connected']。
【问题讨论】:
标签: javascript node.js mongodb object