Post fetch middleware #1935

Closed
MaybiusStrip opened this Issue Feb 22, 2014 · 1 comment

Comments

Projects
None yet
2 participants

Has any thought been given to post-fetch middleware? This would be handy for asynchronous "virtuals."

One use case is if you have parent-child document relationship, the child may have an attribute that can either shadow the same parent attribute or pass through to it. Since this may require fetching the parent model, this is not feasible using virtuals.

I could use a schema method, but then you'd have to remember to call it everytime you fetched the model, which is just bad design and potentially dangerous. I could also update the child whenever I update the parent with a post-save hook, but I'm not a fan of that either, since there is a chance they might fall out of sync (using update instead of save is one I can think of) and it's less explicit.

I'll gladly implement it for myself, I'm just wondering if this has already come up and was deemed problematic, or if there is any interest from anybody else.

Collaborator

vkarpov15 commented Apr 29, 2015

4.0 has query middleware, including for post find.

@vkarpov15 vkarpov15 closed this Apr 29, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment