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.

Mark Ryan Orosa
  • 847
  • 1
  • 6
  • 21
  • 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 https://loopback.io/doc/en/lb3/Fields-filter.html, you could use include, but it also does not exist https://loopback.io/doc/en/lb3/Include-filter.html, there's also chapter on querying related models but it also does not include aggregate functions https://loopback.io/doc/en/lb3/Querying-related-models.html, so... no native way so far – test30 Apr 26 '19 at 14:11

0 Answers0