Skip to content

Commit

Permalink
add positon mapping option to event
Browse files Browse the repository at this point in the history
  • Loading branch information
nanov committed Oct 2, 2018
1 parent a563a53 commit 74debcc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,10 @@ The values describes the path to that property in the event message.
meta: 'meta',

// optional, if defined the commit date of the eventstore will be saved in this value
commitStamp: 'commitStamp'
commitStamp: 'commitStamp',

// optional, if defined and the eventstore db implemntation supports this the position of the event in the eventstore will be saved in this value
position: 'position'
});


Expand Down
15 changes: 11 additions & 4 deletions lib/domain.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,17 @@ _.extend(Domain.prototype, {

this.definitions.event = _.defaults(definition, this.definitions.event);

if (this.definitions.event.commitStamp) {
this.eventStore.defineEventMappings({
commitStamp: this.definitions.event.commitStamp
});
if (this.definitions.event.commitStamp || this.definitions.event.position) {
var mappings = {};
if (this.definitions.event.commitStamp) {
mappings.commitStamp = this.definitions.event.commitStamp;
}

if (this.definitions.event.position) {
mappings.position = this.definitions.event.position;
}

this.eventStore.defineEventMappings(mappings);
}
return this;
},
Expand Down

0 comments on commit 74debcc

Please sign in to comment.