1.0.6 • Published 2 years ago

aqs v1.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

AQS is a query parser library that provides advanced operations comparing to typical query parser libraries. For example, you can use different operators additional to =, or parse values from string to whatever you want and even define complex logic instead of just using and operator for parameters!

Installation

npm install aqs

Usage

Basic

const { parse } = require('aqs');

const parsed = parse('id=3&age=22');

Use other operators

const { parse } = require('aqs');

const parsed = parse('id=3&age{gt}22'); // Greater than

Use negative operators

You can add n prefix to operator names or not_ to full name of operators to make them negative.

const { parse } = require('aqs');

const parsed = parse('id=3&age{ne}22'); // Not equal

Use with config

const { parse } = require('aqs');

const parsed = parse('id=3&age=22', { paramsConfigs: { age: { defaultValue: 20 } } });

Use with custom logic

You can define logic of parameters in logic query string, using parentheses with and and or operators.

Benefit of this feature is that you can allow client side that makes more complex queries instead of simple equal queries.

const { parse } = require('aqs');

const parsed = parse('skill=coding&age=30&experience=8&logic=(and,skill,(or,age,experience))');   // skill==coding and (age==30 or experience==8)

Other features

There are some other features such as defining custom operators, parse values, ... that you can find them in examples folder.

List of operators

OperatorFull-name
eequal
iin
swstartsWith
ewendsWith
gtgreaterThan
ltlessThan
gegreaterOrEqual
lelessOrEqual
bbetween
ccontains
icincludes
llike
ililike
rregex

Configurations

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

3 years ago