From 74debccf057cf5bebff2fd7af692f657d6f1b1c2 Mon Sep 17 00:00:00 2001 From: Dimitar Nanov Date: Tue, 2 Oct 2018 13:25:59 +0300 Subject: [PATCH] add positon mapping option to event --- README.md | 5 ++++- lib/domain.js | 15 +++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 0ac01fe..eda8f94 100644 --- a/README.md +++ b/README.md @@ -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' }); diff --git a/lib/domain.js b/lib/domain.js index bbd269c..45e51b0 100644 --- a/lib/domain.js +++ b/lib/domain.js @@ -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; },