UNPKG

database-builder

Version:

Library to assist in creating and maintaining SQL commands.

49 lines (48 loc) 2.38 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.InsertBuilder = void 0; var insert_columns_builder_1 = require("./insert-columns-builder"); var crud_base_builder_1 = require("../crud-base-builder"); var InsertBuilder = /** @class */ (function (_super) { __extends(InsertBuilder, _super); function InsertBuilder(typeT, mapperTable, alias, _toSave, config) { if (alias === void 0) { alias = void 0; } if (_toSave === void 0) { _toSave = void 0; } var _this = _super.call(this, typeT, mapperTable, config, alias) || this; _this._toSave = _toSave; return _this; } InsertBuilder.prototype.columns = function (columnsCallback) { return _super.prototype.columnsBase.call(this, columnsCallback, this.columnsBuilder, this); }; InsertBuilder.prototype.buildBase = function () { var columnsCompiled = this.getColumnsCompiled(); return this._commanderBuilder.batchInsert(this._tablename, columnsCompiled.columns, columnsCompiled.params); }; InsertBuilder.prototype.getModel = function () { return this._toSave; }; InsertBuilder.prototype.setDefaultColumns = function () { this.columns(function (columns) { return columns.allColumns(); }); }; InsertBuilder.prototype.createColumnsBuilder = function () { return new insert_columns_builder_1.InsertColumnsBuilder(this.mapperTable, this._toSave); }; return InsertBuilder; }(crud_base_builder_1.CrudBaseBuilder)); exports.InsertBuilder = InsertBuilder;