UNPKG

@odata2ts/odata-query-objects

Version:

Q-Objects are the magic sauce for the odata-query-builder and allow for renaming and type conversion

46 lines 1.48 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.QFilterExpression = void 0; class QFilterExpression { constructor(expression) { this.expression = expression; } toString() { var _a; return ((_a = this.expression) === null || _a === void 0 ? void 0 : _a.trim()) || ""; } group() { var _a; if ((_a = this.expression) === null || _a === void 0 ? void 0 : _a.trim()) { return new QFilterExpression(`(${this.expression})`); } return this; } not() { var _a; if ((_a = this.expression) === null || _a === void 0 ? void 0 : _a.trim()) { return new QFilterExpression(`not ${this.expression}`); } return this; } combine(expression, isOrOperation) { if (expression === null || expression === void 0 ? void 0 : expression.toString()) { if (this.expression) { const newExpr = `${this.expression} ${isOrOperation ? "or" : "and"} ${expression.toString()}`; return new QFilterExpression(newExpr); } else { return expression; } } return this; } and(expression) { return this.combine(expression, false); } or(expression) { return this.combine(expression, true); } } exports.QFilterExpression = QFilterExpression; //# sourceMappingURL=QFilterExpression.js.map