Node.js 有没有办法监听 MongoDB 集合中特定数据的更改,并在发生更改时触发事件?
嗯,这是一个老问题,但我也在为同样的事情而苦苦挣扎。我发现了一些花絮帮助我构建了一个解决方案,并且我已将其作为库发布:
https://github.com/TorchlightSoftware/mongo-watch https://github.com/TorchlightSoftware/mongo-watch
该库是用 CoffeeScript 编写的。这是一个 javascript 示例,供喜欢的人参考。
var MongoWatch = require('mongo-watch'),
watcher = new MongoWatch({parser: 'pretty'});
watcher.watch('test.users', function(event) {
return console.log('something changed:', event);
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)