loopback-counts-where-mixin
A mixin to enable get count with condition of related models for a loopback Model. It developed from loopback-counts-mixin
INSTALL
npm install --save loopback-counts-where-mixin
Or
yarn add loopback-counts-where-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
filter: {
...,
counts: ['girlfriends'],
countsWhere: [{ body: 'sexy' }],
countsAs: ['totalGirlfriend']
}
will return list of games with field playersCount
LICENSE
MIT