database-builder
Version:
Library to assist in creating and maintaining SQL commands.
31 lines (30 loc) • 1.17 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.RowMapper = void 0;
var model_utils_1 = require("./model-utils");
var utils_1 = require("./utils");
var RowMapper = /** @class */ (function () {
function RowMapper(_readable) {
this._readable = _readable;
}
RowMapper.prototype.map = function (typeT, expression, alias) {
if (alias === void 0) { alias = void 0; }
var expressionField = utils_1.Utils.getColumn(expression, ".");
var value = this._readable.read(typeT, alias);
if (utils_1.Utils.isNull(this._valueResultMap)) {
this._valueResultMap = {};
}
if (expressionField && expressionField.length > 0) {
model_utils_1.ModelUtils.update(this._valueResultMap, expressionField, function (v) { return model_utils_1.ModelUtils.mergeOverrideEmpty(v, value); });
}
else {
this._valueResultMap = value;
}
return this;
};
RowMapper.prototype.result = function () {
return this._valueResultMap;
};
return RowMapper;
}());
exports.RowMapper = RowMapper;