1 | import { UpdateEvent } from "./event/UpdateEvent";
|
2 | import { RemoveEvent } from "./event/RemoveEvent";
|
3 | import { InsertEvent } from "./event/InsertEvent";
|
4 | import { LoadEvent } from "./event/LoadEvent";
|
5 | /**
|
6 | * Classes that implement this interface are subscribers that subscribe for the specific events in the ORM.
|
7 | */
|
8 | export interface EntitySubscriberInterface<Entity = any> {
|
9 | /**
|
10 | * Returns the class of the entity to which events will listen.
|
11 | * If this method is omitted, then subscriber will listen to events of all entities.
|
12 | */
|
13 | listenTo?(): Function | string;
|
14 | /**
|
15 | * Called after entity is loaded from the database.
|
16 | *
|
17 | * For backward compatibility this signature is slightly different from the
|
18 | * others. `event` was added later but is always provided (it is only
|
19 | * optional in the signature so that its introduction does not break
|
20 | * compilation for existing subscribers).
|
21 | */
|
22 | afterLoad?(entity: Entity, event?: LoadEvent<Entity>): Promise<any> | void;
|
23 | /**
|
24 | * Called before entity is inserted to the database.
|
25 | */
|
26 | beforeInsert?(event: InsertEvent<Entity>): Promise<any> | void;
|
27 | /**
|
28 | * Called after entity is inserted to the database.
|
29 | */
|
30 | afterInsert?(event: InsertEvent<Entity>): Promise<any> | void;
|
31 | /**
|
32 | * Called before entity is updated in the database.
|
33 | */
|
34 | beforeUpdate?(event: UpdateEvent<Entity>): Promise<any> | void;
|
35 | /**
|
36 | * Called after entity is updated in the database.
|
37 | */
|
38 | afterUpdate?(event: UpdateEvent<Entity>): Promise<any> | void;
|
39 | /**
|
40 | * Called before entity is removed from the database.
|
41 | */
|
42 | beforeRemove?(event: RemoveEvent<Entity>): Promise<any> | void;
|
43 | /**
|
44 | * Called after entity is removed from the database.
|
45 | */
|
46 | afterRemove?(event: RemoveEvent<Entity>): Promise<any> | void;
|
47 | }
|