UNPKG

ts-db-helper

Version:
81 lines 2.33 kB
/** * @private * @class QueryPart * * @description * This class is private part of the API. * It is an intermidiate query object for builded query parts * * @author Olivier Margarit * * @since 0.1 */ var QueryPart = /** @class */ (function () { function QueryPart() { /** * @public * @property {string} content string part of the query */ this.content = ''; /** * @public * @property {Array<any>} params the parameters of this part of query */ this.params = []; } /** * @public * @method append append other query part to itself and return itself * to chain appending * * @param {QueryPart} queryPart another query part to append * * @return {QueryPart} the query part itself */ QueryPart.prototype.append = function (queryPart) { this.appendContent(queryPart.content); this.params = this.params.concat(queryPart.params); return this; }; /** * @public * @method appendSub append sub query part * * @param {QueryPart} queryPart the query part to append * * @return {QueryPart} the query part instance to chain operation * * @since 0.2 */ QueryPart.prototype.appendSub = function (queryPart) { if (queryPart instanceof QueryPart) { this.content += ' ('; this.append(queryPart); this.content += ')'; } else { this.content += ' ('; this.content += queryPart.query.trim(); this.content += ')'; this.params = this.params.concat(queryPart.params); } return this; }; /** * @public * @method appendContent append query content to the query part * * @param {string} content the string part to append * * @return {QueryPart} the query part instance to chain operation * * @since 0.2 */ QueryPart.prototype.appendContent = function (content) { this.content = this.content + ' ' + content.trim(); return this; }; return QueryPart; }()); export { QueryPart }; //# sourceMappingURL=query-part.model.js.map