UNPKG

database-builder

Version:

Library to assist in creating and maintaining SQL commands.

97 lines (96 loc) 4.84 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.JoinQueryBuilder = void 0; var where_builder_1 = require("../where-builder"); var query_builder_base_1 = require("./query-builder-base"); var join_type_1 = require("../enums/join-type"); var JoinQueryBuilder = /** @class */ (function (_super) { __extends(JoinQueryBuilder, _super); function JoinQueryBuilder(queryT, onWhereCallback, mapperTable, _typeJoin, alias, getMapper, ignoreQueryFilters) { if (_typeJoin === void 0) { _typeJoin = join_type_1.JoinType.LEFT; } if (alias === void 0) { alias = void 0; } if (ignoreQueryFilters === void 0) { ignoreQueryFilters = true; } var _this = _super.call(this, queryT, mapperTable, alias, getMapper) || this; _this._typeJoin = _typeJoin; _this._ignoreQueryFilter = ignoreQueryFilters; _this._on = new where_builder_1.WhereBuilder(void 0, _this.alias); onWhereCallback(_this._on); return _this; } JoinQueryBuilder.prototype._getInstance = function () { return this; }; JoinQueryBuilder.prototype._getOn = function () { return this.whereCompile(this._on.compile()); }; JoinQueryBuilder.prototype._getTypeJoin = function () { return this._typeJoin; }; JoinQueryBuilder.prototype._getWhere = function () { return this.whereCompiled; }; JoinQueryBuilder.prototype._getProjections = function () { return this._projections; }; JoinQueryBuilder.prototype._getGroupBy = function () { return this._groupBy; }; JoinQueryBuilder.prototype._getHaving = function () { return this._having; }; JoinQueryBuilder.prototype._getOrderBy = function () { return this._orderBy; }; JoinQueryBuilder.prototype._getParams = function () { return this._joinParams; }; JoinQueryBuilder.prototype.addParamsOn = function (params) { this._on._addParams(params); return this; }; // Para adicionar alias da tabela no apelido da projeção padrão JoinQueryBuilder.prototype.createProjectionBuilder = function () { return _super.prototype.createProjectionBuilder.call(this, true, void 0); }; // default false para não adicionar comandos em expressões em join, // ao adicionar o join na consulta principal que será verificado se o commando deve ser adicionado JoinQueryBuilder.prototype.compileWhere = function (current, compiled, addCommand) { if (addCommand === void 0) { addCommand = false; } _super.prototype.compileWhere.call(this, current, compiled, addCommand); }; // default false para não adicionar comandos em expressões em join, // ao adicionar o join na consulta principal que será verificado se o commando deve ser adicionado JoinQueryBuilder.prototype.compileGroupBy = function (groupBy, addCommand) { if (addCommand === void 0) { addCommand = false; } _super.prototype.compileGroupBy.call(this, groupBy, addCommand); }; // default false para não adicionar comandos em expressões em join, // ao adicionar o join na consulta principal que será verificado se o commando deve ser adicionado JoinQueryBuilder.prototype.compileHaving = function (having, addCommand) { if (addCommand === void 0) { addCommand = false; } _super.prototype.compileHaving.call(this, having, addCommand); }; // default false para não adicionar comandos em expressões em join, // ao adicionar o join na consulta principal que será verificado se o commando deve ser adicionado JoinQueryBuilder.prototype.compileOrderBy = function (orderBy, addCommand) { if (addCommand === void 0) { addCommand = false; } _super.prototype.compileOrderBy.call(this, orderBy, addCommand); }; return JoinQueryBuilder; }(query_builder_base_1.QueryBuilderBase)); exports.JoinQueryBuilder = JoinQueryBuilder;