Skip to content

Commit

Permalink
working on readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Petr Janda committed Jan 8, 2012
1 parent d7f4a5e commit b375b7e
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/repository.js
Expand Up @@ -9,6 +9,15 @@ utils.singleton(Repository);
utils.delegators(Repository, 'strategy', 'storeEvent');
utils.delegators(Repository, 'strategy', 'getEventsByAggregate');

/*
* Register new handler function for a given event. Callback is triggered after
* aggregate emit the event of the given type and repository storage system
* is finished saving it to permanent storage.
*
* @param {String} Name of the event.
* @param {Function} Function to be triggered. Event object to be passed as the
* only one parameter.
*/
Repository.prototype.on = function(name, callback) {
this.handlers[name] = this.handlers[name] || [];

Expand Down
26 changes: 26 additions & 0 deletions readme.md
Expand Up @@ -7,6 +7,32 @@ flexible to allow adaptation to your project easy.
As the initial repository, couchdb was chosen for it simple API and architecture which
is very much in sync with event sourcing, one of the key concepts of the solution.

## Install and configure

Node-CQRS is available as npm package.

npm install cqrs

In order to initialize your application. First you need to configure your repository.
At the moment only CouchDB implementation is available and can be initialized with:

var repo = require('cqrs').Repository.getInstance(),
couchdb = require('cqrs').CouchDb.getInstance();

couchdb.database = 'cqrs';
couchdb.options = {
host: 'localhost',
port: 5984
};

repo.strategy = couchdb;

The code above first setup couch db information and then inject it as the permanency
strategy into the repository object. In require statements you can see, that both
repo and couchdb instances were initialized using getInstance() method, which
guarantee, there will be only one instance of those objects, as long as you keep
using it.

## CI Status

![Build Status](https://secure.travis-ci.org/petrjanda/node-cqrs.png?branch=master)

0 comments on commit b375b7e

Please sign in to comment.