0.6.1 • Published 8 months ago

@ambassify/aql-condition v0.6.1

Weekly downloads
15
License
MIT
Repository
github
Last release
8 months ago

aql-condition

Tool to help you build AQL conditions in code.

Usage

npm install --save @ambassify/aql-condition
const Condition = require('@ambassify/aql-condition');

Normalize

Get an normalized version of your condition. This function tries to strip as much irrelevant parts of your condition as it can detect.

condition = Condition.normalize(condition);

Parse

Parse a condition string and normalize it.

const url = `https://foo.com/?condition=${encodeURIComponent(JSON.stringify(condition))}`;
const condition = Condition.parse(url);

Filter

Get a subcondition of a condition by recursively filtering out only the parts you are interested in.

E.g. if you only want parts of the condition that target the "foo" key:

condition = Condition.filter(condition, c => c.key === 'foo');

And / Or / Not

Easily construct normalized and/or/not conditions.

condition = Condition.and(condition, extraCondition);
condition = Condition.or(condition, anotherCondition);
condition = Condtion.and(a, b, c, d, asMuchAsYouWant);
negated = Condition.not(condition);
0.6.1

8 months ago

0.5.0

3 years ago

0.4.1

3 years ago

0.4.0

4 years ago

0.3.0

4 years ago

0.3.1

4 years ago

0.2.0

5 years ago

0.1.1

5 years ago