1.0.1 • Published 5 years ago

loopback-default-filter v1.0.1

Weekly downloads
8
License
ISC
Repository
github
Last release
5 years ago

Loopback Default Filter

This loopback middleware adds a default filter to requests that accept a query

Useage

Install

npm i loopback-default-filter --save

Integrate with Loopback

Include the mixin in your model-config.json file

{
  "mixins": [
    "../node_modules/loopback-default-filter"
  ]
}

Then add the mix in to your model.json file

"mixins": {
  "DefaultFilter": {
    "limit": 10,
    "offset": 0
  }
},

Options

I know there is supposed to be a way to do this through the loopback scope but it had some strange behavior so I just made a mixin to fix this

You can put whatever where filter you want in the mixin opitons

"mixins": {
  "DefaultFilter": {
    "where": {
      "field": 10,
    },
    "offset": 100,
    "limit": 20,
  }
},