Feature Request: AfterEager, AfterAll, BeforeFind, BeforeAll callbacks #557
Labels
f: associations
the associations feature in pop
proposal
A suggestion for a change, feature, enhancement, etc
s: triage
Some tests need to be run to confirm the issue
Milestone
Related: #476
Pop callbacks are limited to afterFind, and before/afterEdit* type hooks.
The Afterfind hook is nice, however it doesn't have any eager relationships, and it can cause performance issues when all is called. Also, there is no way to, in pop, make adjustments or modifcations before a find call (such as to enforce an access check). These issues mean it ends up only being useful for a very limited set of tasks where the relationships are not necessary and there are no DB calls. (This is further exacerbated by #530, however that is a separate issue.)
This means code using Pop needs to write its own implementations of these methods; instead of calling
tx.All(model)
, we have to callmodel.All(tx)
. Ideally, the interface provided by pop would be more extensive, and users would be able to use the connection and query functions for all use cases.Requested Behaviors
AfterEager would be called after all Eager relationships are loaded in a find.
AfterAll would be called after an All request.
AfterEagerAll would be called after an All request after all realtionships are loaded.
BeforeFind would be called directly before loading a record.
BeforeAll would be called directly before an all call.
Additionally, there should be a way to have afterfind/ aftereager not get called when making an all request. This would be a breaking change if we take that away, so maybe we do something similar to eager modes where we can change the callback behavior?
I'm aiming to start a conversation here, so I hope we can get some feedback on this proposal and then move towards some PR's and get these capabilities in.
Info
I am primarily using Pop through Buffalo on macOS.
The text was updated successfully, but these errors were encountered: