mongodb是否在关系数据库中具有触发器和过程之类的属性? [英] does mongodb have the properties such as trigger and procedure in a relational database?

查看:239
本文介绍了mongodb是否在关系数据库中具有触发器和过程之类的属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

包括map-reduce框架 如果要在插入记录之前触发事件以运行一致性检查或安全性操作,该如何使用MongoDB做到这一点?

as the title suggests, include out the map-reduce framework if i want to trigger an event to run a consistency check or security operations before a record is inserted, how can i do that with MongoDB?

推荐答案

MongoDB不支持触发器,但是人们围绕它们创建了解决方案,主要是使用oplog,尽管这仅在您使用副本集运行时才有帮助,因为oplog是一个有上限的集合,可出于复制目的跟踪数据更改. 有关Node.js解决方案,请参见: https://www.npmjs.org/package/mongo-watch 或查看早期的SO线程:如何收听更改为MongoDB集合?

MongoDB does not support triggers, but people have created solutions around them, mostly using the oplog, though this will only help you if you are running with replica sets, as the oplog is a capped collection that keeps track of data changes for the purposes of replication. For a nodejs solution see: https://www.npmjs.org/package/mongo-watch or see an earlier SO thread: How to listen for changes to a MongoDB collection?

如果您担心一致性,请阅读有关mongoDB中的写入问题. http://docs.mongodb.org/manual/core/write-concern/通过设置插入写入关注级别,可以满足您的放松或严格要求,从着火和希望到副本集所有成员的确认.

If you are concerned with consistency, read about write concern in mongoDB. http://docs.mongodb.org/manual/core/write-concern/ You can be as relaxed or as strict as you want by setting insert write concern levels, from fire and hope to getting an acknowledgement from all members of the replica set.

因此,如果要在插入数据之前进行一致性检查,则可能必须将该逻辑移至客户端应用程序,并将写关注级别设置为可确保一致性的级别.

So, if you want to run a consistency check before inserting data, you probably will have to move that logic to the client application and set your write concern level to a level that will ensure consistency.

这篇关于mongodb是否在关系数据库中具有触发器和过程之类的属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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