且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

怎么看MongoDB中的任何变化(新行)?

更新时间:2023-09-29 11:28:46

有MongoDB中没有触发器(没有?),但如果你正在运行的副本集(你应该),您的应用程序可以伪装成一个追赶中学,的 的尾巴在 OPLOG收集并获取新的信息插入/更新。

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).