Is it possible to get informed if something is changed in a collection in mongodb? For example some new document is added to the collection. Is it possible to be subscribed to these changes? Does any implementation for C# exist? Thanks.
When you run MongoDB in a Replica Set, all of the MongoDB actions are logged to an operations log (known as the oplog). The oplog is basically just a running list of the modifications made to the data. Replicas Sets function by listening to changes on this oplog and then applying the changes locally.
Change streams allow applications to access real-time data changes without the complexity and risk of tailing the oplog. Applications can use change streams to subscribe to all data changes on a single collection, a database, or an entire deployment, and immediately react to them.
Instead of tables, a MongoDB database stores its data in collections. A collection holds one or more BSON documents. Documents are analogous to records or rows in a relational database table. Each document has one or more fields; fields are similar to the columns in a relational database table.
MongoDB stores data records as documents (specifically BSON documents) which are gathered together in collections. A database stores one or more collections of documents.
As @Sergio says, not inherently, however you can use a tailable cursor to achieve something similar:
http://blog.mongodb.org/post/29495793738/pub-sub-with-mongodb
Realised that article is a bit bare, this might be a better one: http://www.devco.net/archives/2012/08/31/using-mongodb-as-a-queue.php
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With