Loopback Model - add a count field for a hasMany relation Model
Asked Answered
W

0

7

Is there a way to count the number of instance of a related model, without using an include on the filter?

I already found loopback-counts-mixin, but I am hoping that there is a native way of doing it.

Wingback answered 15/11, 2017 at 23:53 Comment(1)
There's not, there are few potential options, you could use fields filter for introducing new $count field, but it does not offer such a possibility loopback.io/doc/en/lb3/Fields-filter.html, you could use include, but it also does not exist loopback.io/doc/en/lb3/Include-filter.html, there's also chapter on querying related models but it also does not include aggregate functions loopback.io/doc/en/lb3/Querying-related-models.html, so... no native way so farStoneblind

© 2022 - 2024 — McMap. All rights reserved.