Closed
Description
When a LoopBack model is attached a data source, the underlying connector will mix in a list of methods on the model class. If the connector is backed by one of the databases, the methods are the CRUD operations. At the moment, the juggler only has hard-coded before/after hooks that have serious issues:
- The before/after hook only allows one handler
- The triggering of hooks are hard-coded in the lib/dao.js
- Not all paths are covered
See open issues or pull requests:
- fix beforeDestroy and afterDestroy hooks not trigered if called with destroyById #363
- add hooks module and support pre && post #359
- Validators are not triggered on updateOrCreate #262
- beforeDestroy and afterDestroy hooks not trigered if called with destroyById #202
- DataAccessObject.upsert/updateOrCreate - no hooks triggered #159
- Some model hooks ignore errors passed to the callback strongloop/loopback#614
- afterDestroy hook not called on REST remoting (deleteById) #142
Tasks:
- Finish and land Operation hooks for persistent models (intent-based hooks) #403
- Land
before delete
hook Implement intent hookbefore delete
#412 - Update docs draft for
before delete
hook - Write documentation for the new hook API.
- Rename
query
to access (Rename hook "query" to "access" #418) and update docs Clean up change-detection events, let them use the new API - see Refactor change tracking to use the new hook infrastructure strongloop/loopback#1048Addtest/persistence-hooks.suite.js
to connector tests: Not strictly needed, since all hooks are implemented inside juggler.
Out of scope (follow-up):
- Per-method hooks Per-method hooks #397
- Advance hook use-cases Advanced hook use-cases #417
Metadata
Metadata
Assignees
Labels
No labels