Where

The "Where" function provides a comfortable method for filtering a json data.

Github repository for your stars.

Usage

Install

$ npm install json-function

Import

import { where } from 'json-function';

Usage

Example Data

const data = [
  {
    id: 1,
    userId: 1,
    title: "delectus aut autem",
    completed: false,
    education: {
      isDone: true
    }
  },
  {
    id: 2,
    userId: 1,
    title: "lorem ipsum",
    completed: true,
    education: {
      isDone: true
    }
  },
  {
    id: 3,
    userId: 2,
    title: "quis ut nam facilis et officia qui",
    completed: false,
    education: {
      isDone: false
    }
  }
];

Basic Syntax

Output

AND Syntax

Output

OR Syntax

Output

Use "callback" for advanced filter.

Other wh methods.

Deep Where Syntax

It is necessary to add a new option argument to use "Deep Where".

{ deep: true }

Output

Last updated

Was this helpful?