How to see any changes (new row) in mongoDB?

送分小仙女□ 提交于 2019-12-01 07:34:29

问题


Is there any way to observe each collection (or even one) in mongoDB? Now I think about timer to check document number or last Id, but maybe there is some possibility to implement mechanism like newDocumentAddedEvent?


回答1:


There are no triggers in MongoDB (yet?), but if you're running a replica set (as you should), your app can pretend to be a catching-up secondary, tail the oplog collection and get information about new inserts/updates.

This is a very efficient approach (mongodb itself uses it for the replication).



来源:https://stackoverflow.com/questions/10754000/how-to-see-any-changes-new-row-in-mongodb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!