Skip to content
This repository has been archived by the owner on May 29, 2024. It is now read-only.

MongoDB

Samuel Debruyn edited this page Dec 24, 2015 · 3 revisions

Cirqus offers integration with MongoDB on several points.

Installation

To start using any of the components below, install the nuget package.

Install-Package d60.Cirqus.MongoDb 

Event store

You can opt to use MongoDB as an event store. Cirqus will create the collection by itself if it doesn't already exist.

var processor = CommandProcessor.With().EventStore(conf =>
    {
        conf.UseMongoDb("NameOfConnectionStringOrConnectionStringItself", "NameOfCollectionWhereEventsShouldGo");
    }).Create();

Logging

MongoDB is also suited to be used as logging facility. Cirqus will then log all actions to MongoDB. The log collection will contain entries with the following properties:

  • level: Debug, Info, Warn or Error
  • text: what happened
  • time: when it happened
  • owner: what made it happen (either CommandProcessor or ViewManagerEventDispatcher)
var processor = CommandProcessor.With().....Logging(conf =>
{
    conf.UseMongoDb("ConnectionString", "LogCollectionName");
}).Create();

View manager

You can use the MongoDbViewManager to persist a view in MongoDb. You can create one with a connection string or with a MongoDbDatabase object.

var mongoDbMyViewManager = new MongoDbViewManager<MyView>("MongoDbConnectionString");
Clone this wiki locally