You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

MongoDB.ReactiveChangeStream

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

MongoDB.ReactiveChangeStream

MongoDB C# Driver Change Stream Extension using Rx.NET

1.0.1
Source
nugetNuGet
Version published
Maintainers
1
Created
Source

MongoDB.ReactiveChangeStream

Extension for MongoDB C# Driver to handle MongoDB Change Streams as an IObservale MongoDB Change Streams are a feature that allow the database to notify subscribers for any change, more about Change Streams

Installation

First, install the MongoDB.ReactiveChangeStream Nuget package into your app

Install-Package MongoDB.ReactiveChangeStream

Example Usage

using System.Reactive.Linq;
using MongoDB.Bson;
using MongoDB.Driver;
using MongoDB.ReactiveChangeStream;

var client = new MongoClient("mongodb://localhost:27017/foo?replicaSet=rs0");

var database = client.GetDatabase("foo");

var collection = database.GetCollection<BsonDocument>("bar");

var changeObservable = collection.CreateObservableChangeStream(filter =>
    filter.OperationType == ChangeStreamOperationType.Delete ||
    filter.OperationType == ChangeStreamOperationType.Insert ||
    filter.OperationType == ChangeStreamOperationType.Update ||
    filter.OperationType == ChangeStreamOperationType.Replace);

changeObservable
    .Buffer(TimeSpan.FromSeconds(5))
    .Do(changes =>
    {
        // Do something
    })
    .Subscribe();
Note:

Make sure you connecting to a MongoDB instance with Replica Set Enabled, as Change Streams require it. read more about how to initialize a Replica Set here...

Keywords

mongo

FAQs

Package last updated on 30 May 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts