@sqb/builder
Version:
Extensible multi-dialect SQL query builder written with TypeScript
32 lines (31 loc) • 1.09 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.OpExists = void 0;
const enums_js_1 = require("../../enums.js");
const typeguards_js_1 = require("../../typeguards.js");
const comp_operator_js_1 = require("./comp-operator.js");
class OpExists extends comp_operator_js_1.CompOperator {
_operatorType = enums_js_1.OperatorType.exists;
_symbol = 'exists';
constructor(query) {
super(query);
if (!(typeof query === 'object' && (0, typeguards_js_1.isSelectQuery)(query))) {
throw new TypeError('You must provide a SelectQuery in `exists()`');
}
}
_serialize(ctx) {
const left = this.__serializeItem(ctx, this._left);
if (this._isArray)
left.isArray = true;
const o = {
operatorType: this._operatorType,
symbol: this._symbol,
left,
};
return this.__serialize(ctx, o);
}
__defaultSerialize(ctx, o) {
return o.left.expression ? o.symbol + ' ' + o.left.expression : '';
}
}
exports.OpExists = OpExists;