Socket
Socket
Sign inDemoInstall

feathers-query-filters

Package Overview
Dependencies
Maintainers
2
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

feathers-query-filters - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

CHANGELOG.md

4

package.json
{
"name": "feathers-query-filters",
"description": "Adds support for special query string params used for filtering data",
"version": "2.0.0",
"version": "2.0.1",
"license": "MIT",
"homepage": "https://github.com/feathersjs/feathers-query-filters",
"main": "lib/",
"main": "lib/index",
"keywords": [

@@ -9,0 +9,0 @@ "feathers",

@@ -9,92 +9,6 @@ # feathers-query-filters

## Installation
```bash
npm install feathers-query-filters --save
```
## Getting Started
This is used internally in service adapters like [Feathers MongoDB]() and [Feathers NeDB]().
`feathers-query-filters` is used internally the [database service adapters](http://docs.feathersjs.com/databases/readme.html) to support [pagination and sorting](http://docs.feathersjs.com/databases/pagination.html).
Usage is like so:
```js
var Proto = require('uberproto');
var filter = require('feathers-query-filters');
var CustomService = Proto.extend({
init: function(name, options){
// your custom initialization code
},
find: function(params, callback) {
// Start with finding all, and limit when necessary.
var query = this.db.find({});
// Prepare the special query params.
if (params.query) {
var filters = filter(params.query);
// $select uses a specific find syntax, so it has to come first.
if (filters.$select) {
query = this.db.find(params.query, filters.$select);
} else {
query = this.db.find(params.query);
}
// Handle $sort
if (filters.$sort){
query.sort(filters.$sort);
}
// Handle $limit
if (filters.$limit){
query.limit(filters.$limit);
}
// Handle $skip
if (filters.$skip){
query.skip(filters.$skip);
}
}
// Execute the query
query.exec(function(err, docs) {
if (err) {
return callback(err);
}
return callback(err, docs);
});
},
setup: function(app) {
// Called by feathers.configure()
this.app = app;
this.service = app.service.bind(app);
}
});
module.exports = CustomService;
```
## API
The following keywords are supported. They are pulled from the query object's conditions and returned so they can be mapped by each adapter in their own way.
### $sort
### $limit
### $skip
### $select
## Changelog
### 1.0.1
- Adding usage docs
### 1.0.0
- Initial release.
## License

@@ -106,2 +20,2 @@

[Eric Kryski](https://github.com/ekryski)
[Feathers contributors](https://github.com/feathersjs/feathers-query-filters/graphs/contributors)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc