# filter-query

> A simple extractor of filter parameters send by get.

Latest version **1.2.1** (published 2017-04-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install filter-query
pnpm add filter-query
yarn add filter-query
bun add filter-query
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.1 |
| Published | 2017-04-25 |
| First published | 2017-04-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Alexandru Olaru |
| Maintainers | alxolr |

## Links

- npm: https://www.npmjs.com/package/filter-query
- Repository: https://github.com/alxolr/filter-query
- Homepage: https://github.com/alxolr/filter-query#readme
- Issues: https://github.com/alxolr/filter-query/issues
- npm.io page: https://npm.io/package/filter-query

## Recent versions

- 1.2.1 (latest) — 2017-04-25
- 1.1.1 — 2017-04-25
- 1.0.1 — 2017-04-18
- 1.0.0 — 2017-04-11

## README

# Filter Query ![img](https://travis-ci.org/alxolr/filter-query.svg?branch=master)

> This repository has the goal to transform a RESTFULL get filter as the following one
```
/api/v1/books?filter=created_at::>=2016-01-01|created_at::<2016-01-31
```
> into an
```javascript
const createQuery = require('filter-query').createQuery;

const filter = req.query.filter; // an express field
const query = createQuery(filter);

// query = {
//   created_at: {
//    $gte: '2016-01-01',
//    $lt: '2016-01-31'
//   }
// }

Books.find(query)
  .then(processBooks)
  .catch(handleError)
```

## You can use it as express middleware also;
```javascript
const buildQuery = require('filter-query').buildQuery;
const Router = require('express').Router;

Router.route('/api/v1/books')
  .get(buildQuery, getBooks);

function getBooks(req, res) {
  Books.find(req.query) // get the builded query from the middleware
    .then((books) => res.json(books))
    .catch(handleError);
}
```

---
_Source: https://npm.io/package/filter-query · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
