You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -284,13 +279,24 @@ class EventStore extends events.EventEmitter {
284
279
* @returns {this}
285
280
*/
286
281
off(event,listener){
287
-
if(event==='preCommit'||event==='preRead'){
282
+
if(this.isStorageHookEvent(event)){
288
283
this.storage.off(event,listener);
289
284
returnthis;
290
285
}
291
286
returnsuper.off(event,listener);
292
287
}
293
288
289
+
isStorageHookEvent(event){
290
+
returnSTORAGE_HOOK_EVENTS.has(event);
291
+
}
292
+
293
+
delegateStorageHookEvent(method,event,listener){
294
+
if(event==='preCommit'){
295
+
assert(!(this.storageinstanceofReadOnlyStorage),'The storage was opened in read-only mode. Can not register a preCommit handler on it.');
296
+
}
297
+
this.storage[method](event,listener);
298
+
}
299
+
294
300
/**
295
301
* @inheritDoc
296
302
*/
@@ -429,6 +435,20 @@ class EventStore extends events.EventEmitter {
429
435
returntype;
430
436
}
431
437
438
+
getExistingQueryTypes(types){
439
+
constqueryTypes=[];
440
+
for(consttypeoftypes){
441
+
if(typeinthis.streams){
442
+
queryTypes.push(type);
443
+
continue;
444
+
}
445
+
if(!this.typeAccessor){
446
+
thrownewError(`Type stream "${type}" does not exist. Create it with createEventStream() first, or configure typeAccessor to have type streams created automatically on commit.`);
447
+
}
448
+
}
449
+
returnqueryTypes;
450
+
}
451
+
432
452
/**
433
453
* Commit a list of events for the given stream name, which is expected to be at the given version.
434
454
* Note that the events committed may still appear in other streams too - the given stream name is only
@@ -543,20 +563,7 @@ class EventStore extends events.EventEmitter {
assert(Array.isArray(types)&&types.length>0,'Must specify a non-empty array of event types for query.');
546
-
547
-
constqueryTypes=[];
548
-
for(consttypeoftypes){
549
-
if(!(typeinthis.streams)){
550
-
// No typeAccessor: the stream was never created; we cannot know whether events of
551
-
// this type exist in the store, so throw to avoid an unintentional full-store scan.
552
-
assert(!!this.typeAccessor,`Type stream "${type}" does not exist. Create it with createEventStream() first, or configure typeAccessor to have type streams created automatically on commit.`);
553
-
// typeAccessor is configured: type streams are created on commit, so a missing
554
-
// stream simply means no event of this type has been committed yet — treat as empty.
0 commit comments