Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Post fetch middleware #1935

Closed
MaybiusStrip opened this Issue · 1 comment

2 participants

@MaybiusStrip

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.

@vkarpov15
Owner

4.0 has query middleware, including for post find.

@vkarpov15 vkarpov15 closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.