Socket
Socket
Sign inDemoInstall

eventstore

Package Overview
Dependencies
10
Maintainers
2
Versions
93
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.14.2 to 1.14.3

10

lib/base.js

@@ -57,2 +57,12 @@ var util = require('util'),

/**
* Use this function to an array containing the next position numbers
* @param {number} positins Number of positions to provide.
* @param {Function} callback The function, that will be called when the this action is completed.
* `function(err, positions){}` positions is either undefined if option is not enabled/supported or array with positions
*/
getNextPositions: function(positions, callback) {
callback(null);
},
/**
* loads the events

@@ -59,0 +69,0 @@ * @param {Object} query the query object

15

lib/databases/inmemory.js

@@ -66,2 +66,14 @@ var util = require('util'),

getNextPositions: function(positions, callback) {
if (!this.options.trackPosition) {
return callback(null);
}
var range = [];
for(var i=0; i<positions; i++) {
range.push(++this.position);
}
callback(null, range);
},
addEvents: function (events, callback) {

@@ -100,5 +112,2 @@ if (!events || events.length === 0) {

_.forEach(events, function(evt) {
if (self.options.trackPosition) {
evt.position = ++self.position;
}
self.undispatchedEvents._direct[evt.id] = evt;

@@ -105,0 +114,0 @@ });

9

lib/databases/mongodb.js

@@ -317,3 +317,4 @@ var util = require('util'),

var self = this;
this.getNextPositions(events.length, function(err, positions) {
// this.getNextPositions(events.length, function(err, positions) {
/*
if (err) {

@@ -324,2 +325,4 @@ debug(err);

}
*/
_.forEach(events, function (evt, index) {

@@ -336,4 +339,2 @@ if (!evt.aggregateId) {

evt.dispatched = false;
if (positions)
evt.position = positions[index];
});

@@ -384,3 +385,3 @@

});
});
// });
},

@@ -387,0 +388,0 @@

@@ -47,2 +47,3 @@ var debug = require('debug')('eventstore:event'),

this.payload = event || null;
this.position = null;

@@ -49,0 +50,0 @@ this.applyMappings = function applyMappings() {

@@ -490,34 +490,42 @@ var debug = require('debug')('eventstore'),

eventstream.uncommittedEvents = [];
for (var i = 0, len = uncommittedEvents.length; i < len; i++) {
event = uncommittedEvents[i];
event.id = id + i.toString();
event.commitId = id;
event.commitSequence = i;
event.restInCommitStream = len - 1 - i;
event.commitStamp = new Date();
currentRevision++;
event.streamRevision = currentRevision;
event.applyMappings();
}
self.store.getNextPositions(uncommittedEvents.length, function(err, positions) {
if (err)
return callback(err)
self.store.addEvents(uncommittedEvents, function(err) {
if (err) {
// add uncommitted events back to eventstream
eventstream.uncommittedEvents = uncommittedEvents.concat(eventstream.uncommittedEvents);
return callback(err);
}
for (var i = 0, len = uncommittedEvents.length; i < len; i++) {
event = uncommittedEvents[i];
event.id = id + i.toString();
event.commitId = id;
event.commitSequence = i;
event.restInCommitStream = len - 1 - i;
event.commitStamp = new Date();
currentRevision++;
event.streamRevision = currentRevision;
if (positions)
event.position = positions[i];
if (self.publisher && self.dispatcher) {
// push to undispatchedQueue
self.dispatcher.addUndispatchedEvents(uncommittedEvents);
} else {
eventstream.eventsToDispatch = [].concat(uncommittedEvents);
event.applyMappings();
}
// move uncommitted events to events
eventstream.events = eventstream.events.concat(uncommittedEvents);
eventstream.currentRevision();
self.store.addEvents(uncommittedEvents, function(err) {
if (err) {
// add uncommitted events back to eventstream
eventstream.uncommittedEvents = uncommittedEvents.concat(eventstream.uncommittedEvents);
return callback(err);
}
callback(null, eventstream);
if (self.publisher && self.dispatcher) {
// push to undispatchedQueue
self.dispatcher.addUndispatchedEvents(uncommittedEvents);
} else {
eventstream.eventsToDispatch = [].concat(uncommittedEvents);
}
// move uncommitted events to events
eventstream.events = eventstream.events.concat(uncommittedEvents);
eventstream.currentRevision();
callback(null, eventstream);
});
});

@@ -524,0 +532,0 @@ }],

{
"author": "adrai",
"name": "eventstore",
"version": "1.14.2",
"version": "1.14.3",
"contributors": [

@@ -6,0 +6,0 @@ {

@@ -0,1 +1,4 @@

#### [v1.14.3](https://github.com/adrai/node-eventstore/compare/v1.40.3...v1.14.2)
- revisit the position option, to make it mappable to payload and part of the commit flow
#### [v1.14.2](https://github.com/adrai/node-eventstore/compare/v1.40.1...v1.14.2)

@@ -2,0 +5,0 @@ - add non-breaking, optional position in store option for mongodb and inmemory implementations

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc