New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@comodinx/query-filters

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@comodinx/query-filters

@comodinx/query-filters is a module for parsing filters in string to object.

latest
Source
npmnpm
Version
1.0.1
Version published
Weekly downloads
64
-7.25%
Maintainers
1
Weekly downloads
 
Created
Source

Query Filters

@comodinx/query-filters is a module for parsing filters in string to object.

Index

  • Download & Install.
  • How is it used?.
  • Tests.

Download & Install

NPM

$ npm install @comodinx/query-filters

Source code

$ git clone https://github.com/comodinx/query-filters.git
$ cd query-filters
$ npm install

How is it used?

Simple usage

const { Parser } = require('@comodinx/query-filters');
const parser = new Parser();

parser.parse('active eq 1,description li %casa');
// { "active": { "eq": "1" }, "description": { "li": "%casa" } }

parser.parse('active eq 1,description li %casa,description eq depto');
// { "active": { "eq": "1" }, "description": { "li": "%casa", "eq": "depto" } }

Logical operators and groups

AND

  • Default operator
  • Represented by ,
active eq 1,description li %casa

OR

  • Represented by |
active eq 1|description li %casa

Groups

  • Represented by ( and )
active eq 1,(description li %casa|description eq depto)

Precedence

  • AND has higher precedence than OR
  • Use groups to control evaluation order
active eq 1,description li %casa|age ge 18
active eq 1,(description li %casa|age ge 18)

Parsed result example

parser.parse('active eq 1,(deleted_at is null|age ge 18)');
/*
{
  active: { eq: 1 },
  or: [
    { deleted_at: { is: 'null' } },
    { age: { ge: 18 } }
  ]
}
*/

Operators

NameExampleDescription
eqid eq 1Check equality. id = 1
nename ne nicoCheck inequality. name != 'nico'
gtid gt 1Check greater than. id > 1
geid ge 10Check greater than or equal. id >= 10
ltid lt 1Check less than. id < 1
leid le 10Check less than or equal. id <= 10
liname li nico%Check matches with nico*. name like nico%
nlname nl nico%Check not matches with nico*. name not like nico%
inid in [1;2;3]Check if included on [1,2,3]. id in (1,2,3)
niid ni [1;2;3]Check if not included on [1,2,3]. id not in (1,2,3)
beid be [1;10]Check if it is between a and b. id between (1 and 10)
nbid nb [1;10]Check if it is not between a and b. id not between (1 and 10)
isdeleted_at is nullCheck if it is null.
nodeleted_at is not nullCheck if it is not null.

Configurations

NameTypeDefaultDescription
logicalsobject`{ or: '', and: ',' }`
keystring"[A-Za-z0-9_]+"RegExp string for matching keys.
valuestring".+"RegExp string for matching values.
operatorsarray['eq','ne','gt','ge','lt','le','li','nl','in','ni','be','nb','is','no']
operatorPrefixstring" "Operator prefix.
operatorSuffixstring" "Operator suffix.
operatorFlagsstring"i"Operator regexp flag.
separatorGroupsstring";"List values separator.
groupsobject{ start: '(', end: ')' }Conditions group delimiters.

Format

const parser = new Parser();

parser.format({
  active: { eq: 1 },
  description: { li: '%casa' },
  or: [
    { deleted_at: { is: 'null' } },
    { age: { ge: 18 } }
  ]
});
// "active eq 1,description li %casa,(deleted_at is null|age ge 18)"

Tests

In order to see more concrete examples, I INVITE YOU TO LOOK AT THE TESTS :)

Run the unit tests

npm install
npm test

Keywords

query

FAQs

Package last updated on 16 Jan 2026

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