<commit_before>## eventric MongoDB Store Adapter [![Build Status](https://travis-ci.org/efacilitation/eventric-store-mongodb.svg?branch=master)](https://travis-ci.org/efacilitation/eventric-store-mongodb)


## API


### initialize(contextName, options, callback)

`contextName` String Name of the context for which the store is responsible

`options{}` Object with options

* `host` The Host to which the MongoDb should connect (default: `127.0.0.1`)
* `port` The Port to which the MongoDb should connect (default: `27017`)
* `database` The name of the Database to which MongoDb should connect (default: `eventric`)
* `schema` The schema which we use to connect (default: `mongodb://`)
* `dbInstance` Already initialized mongo.Db (default: null), wont connect at all if provided


`callback(error)`

* `error` null or Error if one happened


### saveDomainEvent(domainEvent, callback)

`domainEvent` The DomainEvent to be stored

`callback(error, domainEvents)`

* `error` null or Error if one happened
* `domainEvents` The stored domainEvents in an array


### findDomainEventsByName(domainEventName, callback)

Finds DomainEvents with the given Name in Store

`domainEventName` String|Array Name, or array of names, of the DomainEvent

`callback(error, domainEvents)`

* `error` null or Error if one happened
* `domainEvents` The domainEvents found


### findDomainEventsByAggregateId(aggregateId, callback)

Finds DomainEvents with the given AggregateId in Store

`aggregateId` String|Array Id, or array of ids, of the Aggregate

`callback(error, domainEvents)`

* `error` null or Error if one happened
* `domainEvents` The domainEvents found


### findDomainEventsByNameAndAggregateId(domainEventName, aggregateId, callback)

Finds DomainEvents with the given AggregateName in the Store

`domainEventName` String|Array Name, or array of names, of the DomainEvent

`aggregateId` String|Array Id, or array of ids, of the Aggregate

`callback(error, domainEvents)`

* `error` null or Error if one happened
* `domainEvents` The domainEvents found



### getProjectionStore(projectionName, callback)

callbacks with a mongodb collection which can be used for a projection

`projectionName` Name of the Projection for which a projectionStore should be returned

`callback(error, projectionStore)`

* `error` null or Error if one happened
* `projectionStore` MongoDb Collection Projection Store


### clearProjectionStore(projectionName, callback) ->

clears the projectionStore with the given name

`projectionName` Name of the Projection which should be cleared

`callback(error, result)`

* `error` null or Error if one happened
* `result` Result of the dropCollection call




## Running Tests

**Attention** The specs will need a running MongoDB instance available at `mongodb://127.0.0.1:27017`. They create and remove a database named `__eventric_tests`.


Install dependencies

```
npm install
```

Execute specs and watcher

```
gulp watch
```<commit_msg>Touch readme.md to trigger travis<commit_after>## eventric MongoDB Store Adapter [![Build Status](https://travis-ci.org/efacilitation/eventric-store-mongodb.svg?branch=master)](https://travis-ci.org/efacilitation/eventric-store-mongodb)


## API


### initialize(contextName, options, callback)

`contextName` String Name of the context for which the store is responsible

`options{}` Object with options

* `host` The Host to which the MongoDb should connect (default: `127.0.0.1`)
* `port` The Port to which the MongoDb should connect (default: `27017`)
* `database` The name of the Database to which MongoDb should connect (default: `eventric`)
* `schema` The schema which we use to connect (default: `mongodb://`)
* `dbInstance` Already initialized mongo.Db (default: null), wont connect at all if provided


`callback(error)`

* `error` null or Error if one happened


### saveDomainEvent(domainEvent, callback)

`domainEvent` The DomainEvent to be stored

`callback(error, domainEvents)`

* `error` null or Error if one happened
* `domainEvents` The stored domainEvents in an array


### findDomainEventsByName(domainEventName, callback)

Finds DomainEvents with the given Name in Store

`domainEventName` String|Array Name, or array of names, of the DomainEvent

`callback(error, domainEvents)`

* `error` null or Error if one happened
* `domainEvents` The domainEvents found


### findDomainEventsByAggregateId(aggregateId, callback)

Finds DomainEvents with the given AggregateId in Store

`aggregateId` String|Array Id, or array of ids, of the Aggregate

`callback(error, domainEvents)`

* `error` null or Error if one happened
* `domainEvents` The domainEvents found


### findDomainEventsByNameAndAggregateId(domainEventName, aggregateId, callback)

Finds DomainEvents with the given AggregateName in the Store

`domainEventName` String|Array Name, or array of names, of the DomainEvent

`aggregateId` String|Array Id, or array of ids, of the Aggregate

`callback(error, domainEvents)`

* `error` null or Error if one happened
* `domainEvents` The domainEvents found



### getProjectionStore(projectionName, callback)

callbacks with a mongodb collection which can be used for a projection

`projectionName` Name of the Projection for which a projectionStore should be returned

`callback(error, projectionStore)`

* `error` null or Error if one happened
* `projectionStore` MongoDb Collection Projection Store


### clearProjectionStore(projectionName, callback) ->

clears the projectionStore with the given name

`projectionName` Name of the Projection which should be cleared

`callback(error, result)`

* `error` null or Error if one happened
* `result` Result of the dropCollection call




## Running Tests

**Attention** The specs will need a running MongoDB instance available at `mongodb://127.0.0.1:27017`. They create and remove a database named `__eventric_tests`.


Install dependencies

```
npm install
```

Execute specs and watcher

```

gulp watch
```
{'fraction_non_alphanumeric': 0.08934881373043917, 'fraction_numerical': 0.00740366818105334, 'mean_word_length': 5.539053905390539, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6213467', 'n_tokens_mistral': 1772, 'n_tokens_neox': 1675, 'n_words': 668}