Applying simplified Domain Repository with MongoDB

I’m interested in cqrs,event sourcing and ddd concepts in the last few months.I have read many many blog post,books and presentations and I looked at several source code at github.After a few unsuccessful attempts,I developed a generic repository for our domain and aggregates.To be honest,I didn’t want to develop a domain repository for every single domain object.Let’s focus on the following interface.

I have an AggregateRootBase for all domain objects.So, what exactly does AggregateRootbase look like?

Do all domain objects have to purgeable? In fact, the answer is not certain.It  depents on your structure, your business requirements or your ubiquitous language.

What does purgeable mean? If you want to delete domain objects from repository in some cases, you can mark as purgeable.

Anyway, see below for implementation of IDomainRepository.

We can use any source for domain repository like sql,oracle,postgresql,couchbase etc.But I choose mongodb cause of Eventual Consistency.Anyway, lets try mongodb implementation.

Firstly, I created a base object for MongoDb settings.

 

And then ,I developed an implementation.

Well, how exactly did I use it? I used it in every command handler.

 

Happy codings!