Aggregate Events
Introduction
Aggregate events are triggered when performing aggregate operations.
Types of Events
There are three types of events in the Aggregate:
fetching: This event is triggered when callingget,first,latest,oldestorcountmethods.updating: This event is triggered when callingupdatemethod.deleting: This event is triggered when callingdeletemethod.
Accessing Aggregate Events
To access the Aggregate events manager, call the events() method on the Aggregate class (not the instance).
src/app.ts
import { Aggregate } from "@mongez/monpulse";
Aggregate.events()
.onFetching((aggregate) => {
// do something
})
.onUpdating((aggregate) => {
// do something
})
.onDeleting((aggregate) => {
// do something
});