loopback-ds-resultset-limit-mixin

1.0.6 • Public • Published

RESULTSET LIMIT

Greenkeeper badge

Circle CI Coverage Status Dependencies semantic-release

This module is designed for the Strongloop Loopback framework. It provides a mixin that makes it possible to limit the number of results returned from an API query.

This works in a similar way to a default scope - the difference being that it acts as a maximum limit constraint ensuring that no more results than the configured maximum will be served by the api, even if requested.

This affects remote remote API calls only and does not apply to internal usage of the API.

INSTALL

npm install --save loopback-ds-resultset-limit-mixin

Then you should register the mixin in your app by adding ../node_modules/loopback-ds-resultset-limit-mixin/lib to the mixins property to your server/model-config.json like the following:

{
  "_meta": {
    "sources": [
      "loopback/common/models",
      "loopback/server/models",
      "../common/models",
      "./models"
    ],
    "mixins": [
      "loopback/common/mixins",
      "../node_modules/loopback-ds-resultset-limit-mixin/lib",
      "../common/mixins"
    ]
  }
}
 

CONFIG

To use with your Models add the mixins attribute to the definition object of your model config.

  {
    "name": "Item",
    "properties": {
      "name": "String",
      "description": "String",
      "status": "String"
    },
    "mixins": {
      "ResultsetLimit": {
        "limit": 100
      }
    }
  }

TESTING

Run the tests in test.js

  npm test

Run with debugging output on:

  DEBUG='loopback:mixin:resultset-limit' npm test

Package Sidebar

Install

npm i loopback-ds-resultset-limit-mixin

Weekly Downloads

365

Version

1.0.6

License

MIT

Last publish

Collaborators

  • fullcube-public
  • mrfelton