# loopback-filters

> Apply LoopBack filters to Arrays

Latest version **1.1.1** (published 2020-09-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install loopback-filters
pnpm add loopback-filters
yarn add loopback-filters
bun add loopback-filters
```

## 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.1.1 |
| Published | 2020-09-01 |
| First published | 2015-06-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4.0.0 |
| Dependencies | 1 |
| Unpacked size | 26.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 54 |
| Author | IBM Corp. |
| Maintainers | bajtos, dhmlau, emonddr, hacksparrow, jannyhou2016, rfeng, rmg |
| Keywords | LoopBack, filter, sort, sorting, query |

## Links

- npm: https://www.npmjs.com/package/loopback-filters
- Repository: https://github.com/strongloop/loopback-filters
- Issues: https://github.com/strongloop/loopback-filters/issues
- npm.io page: https://npm.io/package/loopback-filters

## Dependencies (1)

- [debug](https://npm.io/package/debug.md) ^3.1.0

## Alternatives

- [gamedig](https://npm.io/package/gamedig.md) — 29.3K weekly downloads
- [join-monster](https://npm.io/package/join-monster.md) — 12.8K weekly downloads
- [masked](https://npm.io/package/masked.md) — 5.5K weekly downloads
- [@comunica/actor-query-process-explain-logical](https://npm.io/package/@comunica/actor-query-process-explain-logical.md) — 4.7K weekly downloads
- [@veracity/vui](https://npm.io/package/@veracity/vui.md) — 4.6K weekly downloads

## Recent versions

- 1.1.1 (latest) — 2020-09-01
- 1.1.0 — 2020-03-06
- 1.0.0 — 2017-12-05
- 0.1.3 — 2016-10-13
- 0.1.2 — 2016-05-06
- 0.1.1 — 2015-06-23

## README

# loopback-filters

**⚠️ LoopBack 3 is in Maintenance LTS mode, only critical bugs and critical
security fixes will be provided. (See
[Module Long Term Support Policy](#module-long-term-support-policy) below.)**

We urge all LoopBack 3 users to migrate their applications to LoopBack 4 as
soon as possible. Refer to our
[Migration Guide](https://loopback.io/doc/en/lb4/migration-overview.html)
for more information on how to upgrade.

## Overview

This module implements LoopBack style filtering **without any dependencies on
LoopBack**.

## Install

```sh
$ npm install loopback-filters
```

## Usage

Below is a basic example using the module

```js
var applyFilter = require('loopback-filters');
var data = [{foo: 'bar'}, {bat: 'baz'}, {foo: 'bar'}];
var filter = {where: {foo: 'bar'}};

var filtered = applyFilter(data, filter);

console.log(filtered);
```

The output would be:

```js
[{foo: 'bar'}, {foo: 'bar'}]
```

## Features

**[Where](http://docs.strongloop.com/display/public/LB/Where+filter)**

```js
// return items where
applyFilter({
  where: {
    // the price > 10 && price < 100
    and: [
      {
        price: {
          gt: 10
        }
      },
      {
        price: {
          lt: 100
        }
      },
    ],

    // match Mens Shoes and Womens Shoes and any other type of Shoe
    category: {like: '.* Shoes'},

    // the status is either in-stock or available
    status: {inq: ['in-stock', 'available']}
  }
})
```

Only include objects that match the specified where clause. See [full list of supported operators](http://docs.strongloop.com/display/public/LB/Where+filter#Wherefilter-Operators).

**[Geo Filter / Near](http://docs.strongloop.com/display/public/LB/Where+filter#Wherefilter-near)**

```js
applyFilter(data, {
  where: {
    location: {near: '153.536,-28'}
  },
  limit: 10
})
```

Sort objects by distance to a specified `GeoPoint`.

**[Order](http://docs.strongloop.com/display/public/LB/Order+filter)**

Sort objects by one or more properties.

**[Limit](http://docs.strongloop.com/display/public/LB/Limit+filter) / [Skip](http://docs.strongloop.com/display/public/LB/Skip+filter)**

Limit the results to a specified number. Skip a specified number of results.

**[Fields](http://docs.strongloop.com/display/public/LB/Fields+filter)**

Include or exclude a set of fields in the result.

**Note: [Inclusion](http://docs.strongloop.com/display/public/LB/Include+filter) from loopback is not supported!**

## Docs

[See the LoopBack docs](http://docs.strongloop.com/display/public/LB/Querying+data) for the filter syntax.

## Module Long Term Support Policy

This module adopts the [
Module Long Term Support (LTS)](http://github.com/CloudNativeJS/ModuleLTS) policy,
 with the following End Of Life (EOL) dates:

| Version | Status          | Published | EOL      |
| ------- | --------------- | --------- | -------- |
| 1.x     | Maintenance LTS | Dec 2017  | Dec 2020 |

Learn more about our LTS plan in [docs](https://loopback.io/doc/en/contrib/Long-term-support.html).

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