loopback icon indicating copy to clipboard operation
loopback copied to clipboard

Support for Calculated Attributes dependent on related models

Open michael-lumley opened this issue 11 years ago • 9 comments

I was disappointed with the lack of support for calculated attributes dependent on related models and wrote a plugin to implement that functionality. I wanted to bring that plugin to the attention of the developers in the event that they were interested in implementing that functionality in future releases. I'm confident that there are others out there who would find the functionality useful as well.

michael-lumley avatar Mar 04 '15 17:03 michael-lumley

Would be great to have this in Loopback.

@michael-lumley would you mind creating a pull request with your plugin?

smehrbrodt avatar May 12 '15 13:05 smehrbrodt

@smehrbrodt I'm a little hesitant to do that, for a couple of reasons - first and foremost, I'm a lawyer by training, programming is just a hobby for me, so I'm not totally confident that the plugin won't break under certain use cases. Second, I don't want to step on the toes of the project leads - I don't want to muck up the project with some unconventional code. Finally, the code is available at the link above to those who'd like to implement it for themselves, and by including it in a module or a bootscript, you can make sure that it doesn't get overwritten by subsequent releases of the main loopback project.

Thanks for the thought, though!

michael-lumley avatar May 13 '15 12:05 michael-lumley

Would definitely use this if it were merged.

gausie avatar Jun 22 '15 12:06 gausie

+1

cloudlena avatar Aug 13 '15 22:08 cloudlena

@michael-lumley Feel free to submit a PR, if anything looks odd, we'll give you feedback. ;)

superkhau avatar Aug 13 '15 23:08 superkhau

:+1: Would be a great feature.

shuckepco avatar Aug 25 '15 07:08 shuckepco

I just figured out that this can actually be solved pretty conveniently with operational hooks. I posted a sample here: https://stackoverflow.com/questions/25438663/dynamic-properties-or-aggregate-functions-in-loopback-models/32285839#32285839

From my point of view this solves this issue and it can therefore be closed.

cloudlena avatar Aug 29 '15 12:08 cloudlena

You can also use our computed property mixin - https://github.com/fullcube/loopback-ds-computed-mixin

mrfelton avatar Aug 30 '15 16:08 mrfelton

@michael-lumley: looks like you can use the two work arounds above or open a PR for us to merge (to speed up the process). Going to close, please re-open if you still require this.

pthieu avatar Nov 03 '16 20:11 pthieu