怎么看MongoDB中的任何变化(新行)? [英] How to see any changes (new row) in mongoDB?

查看:121
本文介绍了怎么看MongoDB中的任何变化(新行)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么办法来观察的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中没有触发器(没有?),但如果你正在运行的副本集(你应该),您的应用程序可以伪装成一个追赶中学,的 的尾巴在 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).

这篇关于怎么看MongoDB中的任何变化(新行)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆