1.1.7 • Published 2 years ago

@johanmnto/query v1.1.7

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

@johanmnto/query

An easy query string library.

Get started

Install this library: pnpm i @johanmnto/query

How to use

Use a query string with a single condition

A query string with a single condition is created by calling Query.New.[isEqual,isLower,isHigher]. You can call the appropriate comparison mode to handle your query string, other comparison modes may be added later.

// create a query string to compare a remote value with 12
// you can read it as `remoteValue` < 12
const someCondition = Query.New.isLower(12);

// to run a query string, use `Query.Handle.Process`
Query.Handle.Process(
    // put here your query string
    someCondition,
    // put here the remote value of your query
    8
).result(); // true

Use a query string with multiple conditions

To use a query string with multiple conditions, you need to build a query group. To do so, the Query.NewGroup will be used to build it. It works by combining multiple query string together.

const someCondition = Query.NewGroup(Query.New.isLower(12), Query.New.isHigher(6));
Query.Handle.ProcessGroup(someCondition, 10).result(); // true

Advanced usage

Use flags with a query string

Flags are useful because they describe how the Query processor will behave. They can be set using withFlags after Query.New. Flags are defined on Query.Flags.

// this query will apply the condition to each item of an array 
const someFlaggedCondition = Query.New.withFlags(Query.Flags.ForEachItem).isEqual("ab");
Query.Handle.Process(someFlaggedCondition, ["bg", "ab"]).result(); // false
1.1.7

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.0

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago