@acuris/eventstore-api
Advanced tools
Comparing version 1.3.4 to 1.3.5
@@ -37,2 +37,3 @@ import { EventBatchWriter, EventHeader, EventReader, EventRecord, EventSource, EventStreamReader, EventStreamWriter, NewEvent, Position, PositionCodec, ResolvedEvent, ResolvedEventHeader, StreamId } from "./EventSource"; | ||
write(streamId: StreamId, events: NewEvent[], expectedEventNumber?: number): Promise<void>; | ||
writeAsAt(timestamp: Date, streamId: StreamId, events: NewEvent[], expectedEventNumber?: number): Promise<void>; | ||
private lastEventNumber; | ||
@@ -39,0 +40,0 @@ close(): Promise<void>; |
@@ -93,4 +93,6 @@ "use strict"; | ||
write(streamId, events, expectedEventNumber) { | ||
return this.writeAsAt(new Date(), streamId, events, expectedEventNumber); | ||
} | ||
writeAsAt(timestamp, streamId, events, expectedEventNumber) { | ||
let lastEventNumber = this.lastEventNumber(streamId); | ||
const timestamp = new Date(); | ||
if (expectedEventNumber !== undefined && lastEventNumber !== expectedEventNumber) | ||
@@ -97,0 +99,0 @@ return Promise.reject(new Error(`Wrong expected version ${streamId.category}/${streamId.id}: at ${lastEventNumber}, expected ${expectedEventNumber}`)); |
{ | ||
"name": "@acuris/eventstore-api", | ||
"private": false, | ||
"version": "1.3.4", | ||
"version": "1.3.5", | ||
"description": "API for accessing event stores", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
18943
428