1.1.1 • Published 3 years ago

querycheck v1.1.1

Weekly downloads
3
License
MIT
Repository
github
Last release
3 years ago

Jest unit testing

QueryCheck

QueryCheck is a logical JSON query evaluator which uses the MongoDB query style.

The following comparision operators are supported:

As well as the following logical operators:

Installation

Install with npm:

$ npm install querycheck

Simple example

const QueryCheck = require('querycheck');

const vars = {
    now: {
        isoDate: "2020-05-21",
        isoTime: "13:59:48",
    }
};

const openingHours = new QueryCheck(
    {
        "now.isoDate": {
            "$not": {
                "$in": ["2019-12-25", "2019-12-26", "2019-12-31", "2020-01-01"]
            }
        },
        "now.isoTime": {
            "$gt": "10:00",
            "$lt": "18:00"
        }
    }
);

if (openingHours.test(vars)) {
    console.log("We're OPEN!");
} else {
    console.log("Sorry, we're CLOSED!");
}

License

QueryCheck is available under the MIT license.