UNPKG

redis-time-series-ts

Version:
59 lines (58 loc) 2.09 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.FilterBuilder = void 0; const filterOperator_1 = require("../enum/filterOperator"); const filter_1 = require("../entity/filter"); /** * A Filter object for use in queries */ class FilterBuilder { /** * The label and value in the constructor create a first filter where label=value. * More filters can be created by calling the different methods in FilterBuilder * * @param label the label of the first filter * @param value the value represented by the label * * @remarks * ``` * // Example * const aggregation = new Aggregation(AggregationType.MAX, 5000); * const timestampRange = new TimestampRange(date, date + 10000); * const filter = new FilterBuilder("label", 1).equal("sensor", 1); * const multiRanges = await redisTimeSeries.multiRange(timestampRange, filter, undefined, aggregation, true); * ``` */ constructor(label, value) { this.filters = []; this.equal(label, value); } equal(label, value) { this.filters.push(new filter_1.Filter(label, filterOperator_1.FilterOperator.EQUAL, value)); return this; } notEqual(label, value) { this.filters.push(new filter_1.Filter(label, filterOperator_1.FilterOperator.NOT_EQUAL, value)); return this; } notExists(label) { this.filters.push(new filter_1.Filter(label, filterOperator_1.FilterOperator.EQUAL)); return this; } exists(label) { this.filters.push(new filter_1.Filter(label, filterOperator_1.FilterOperator.NOT_EQUAL)); return this; } in(label, value) { this.filters.push(new filter_1.Filter(label, filterOperator_1.FilterOperator.EQUAL, value)); return this; } notIn(label, value) { this.filters.push(new filter_1.Filter(label, filterOperator_1.FilterOperator.NOT_EQUAL, value)); return this; } get() { return this.filters; } } exports.FilterBuilder = FilterBuilder;