In addition to the standard Node events, LoopBack applications and models emit other events.
Application events
By default, the scaffolded application emits a 'started' event when it starts up, after running boot scripts.
Model events
The following table summarizes the events that LoopBack models can emit.
Event | Emitted when... | Arguments | Argument type | Class methods that emit | Instance methods that emit |
---|---|---|---|---|---|
'attached' | Model is attached to an app.
| Model class | Object | app.model(modelName) | |
'changed' | Model instance is created, saved, or updated. | Model instance | Object |
|
|
'dataSourceAttached' | Model is attached to a Data source. | Model class | Object |
| |
'deleted' | Model instance is deleted. | Model ID | Number |
|
|
'deletedAll' | Model instance is deleted. | where (optional) | JSON object |
| |
'set' | Model property is set. | Model instance | Object | Model.prototype.setAttributes() |
Other events:
User.resetPassword()
emits the 'resetPasswordRequest' event.