loopback-custom-counts-mixin
A mixin to enable get count of related models for a loopback Model.
fork from exromany/loopback-counts-mixin to accommodate b3rew/loopback-row-count-mixin
INSTALL
npm install --save loopback-custom-counts-mixin
There are 2 ways to enable mixin:
1) server.js
In your server/server.js file add the following line before the boot(app, __dirname); line.
...var app = moduleexports = ;...// Add Counts Mixin to loopbackapp; ;
2) mixin sources
Add the mixins property to your server/model-config.json like the following:
CONFIG
To use with your Models add the mixins
attribute to the definition object of your model config.
USAGE
In fetching data with counts
filter, will added field named like relationnameCount
EXAMPLE
http://0.0.0.0:3000/api/games?filter={"counts":"players"}
will return list of games with field playersCount
LICENSE
MIT