loopback-extra-query-filters
v1.0.5
Published
Extra query filters for loopback models
Downloads
4
Maintainers
Readme
Loopback extra query filters
This package provides extra query filters for loopback.
The extra filters do not change queries generated by loopback-datasource-juggler, but are applied to the resulting object.
Installation
Reference mixins in server/model-config.js
{
"_meta": {
...
"mixins": [
...
"../node_modules/loopback-extra-query-filters/mixins"
]
}
}
{
"name": "note",
"base": "PersistedModel",
...
"mixins": {
"ExtraQueryFilters" : true
}
"properties": {
...
},
...
}
Extra query filters
- has - Check if you have the property.
- notHas - Check if you do not have the property.
- isEmpty -Check if array property is empty
- isNotEmpty - Check if array property is not empty.
Examples
- Filter:
// Product has category (Ex.: relation belongsTo)
{
"include": {
"relation": "category",
},
"has": "category" //or ["category", ...]
}
// Product has no category (Ex.: relation belongsTo)
{
"include": {
"relation": "category",
},
"notHas": "category" //or ["category", ...]
}
// Product without items (Ex.: relation hasMany)
{
"include": {
"relation": "items",
},
"isEmpty": "items" //or ["items", ...]
}
// Product with items (Ex.: relation hasMany)
{
"include": {
"relation": "items",
},
"isNotEmpty": "items" //or ["items", ...]
}