Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

boosterfilters

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

boosterfilters

Sequalize filter DSL

latest
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

BoostFilters

BoostFilters is a JavaScript package that generates Sequelize filters from a provided dictionary. It supports a wide range of filter types, including full-text search, greater than, less than, equals, and more.

Installation

Install BoostFilters via npm:

npm install boostfilters

or via yarn:

yarn add boostfilters

Usage

First, import the generateFilterConditions function from the boostfilters package:

import { generateFilterConditions } from "boostfilters";

you can use it to build Sequelize queries:

const filters = {
  "name.fulltext": "John Doe",
  "age.greaterThan": 30,
  "createdAt.range": ["2022-01-01", "2023-01-01"],
};

const sequelizeFilters = generateFilterConditions(filters);

// Use `sequelizeFilters` in your Sequelize queries

In this example, sequelizeFilters will be an object suitable for use in a Sequelize where clause.

Query Types The generateFilterConditions function supports a variety of query types:

The keys of the query object should be the name of the field you want to query on, followed by a period and the type of the query. Here's a brief overview of each type:

  • fieldName.fulltext: Performs a "LIKE" search on fieldName. Matches any records where fieldName contains the provided value.

  • fieldName.equals: Matches any records where fieldName is exactly equal to the provided value.

  • fieldName.greaterThan: Matches any records where fieldName is greater than the provided value.

  • fieldName.lessThan: Matches any records where fieldName is less than the provided value.

  • fieldName.range: Matches any records where fieldName is within the provided range. The value for this query type should be an array with two elements: the start of the range and the end of the range.

  • fieldName.between: Matches any records where fieldName is between the two provided values.

  • fieldName.lessThanOrEqual: Matches any records where fieldName is less than or equal to the provided value.

fieldName.greaterThanOrEqual: Matches any records where fieldName is greater than or equal to the provided value.

You can also query associated tables by using the name of the associated table as a prefix to the field name, separated by a period. For example, to query the name field on an associated users table entries, you would use the key users.name.fulltext.

FAQs

Package last updated on 23 May 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts