问题描述
有什么办法来观察的MongoDB
每个集
(甚至一)?现在,我想定时检查证件号码或最后一个ID,但也许有一些可能性来实现,比如 newDocumentAddedEvent
?
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
?
推荐答案
有MongoDB中没有触发器(没有?),但如果你正在运行的(你应该),您的应用程序可以伪装成一个追赶中学,的的尾巴在并获取新的信息插入/更新。
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.
这是一种非常有效的方法(MongoDB的本身使用它的复制)。
This is a very efficient approach (mongodb itself uses it for the replication).
这篇关于怎么看MongoDB中的任何变化(新行)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!