Skip to content

Instantly share code, notes, and snippets.

@phanviet
Last active March 17, 2020 04:46
Show Gist options
  • Save phanviet/a52f9447f07edcdecc10543ca1fbdb46 to your computer and use it in GitHub Desktop.
Save phanviet/a52f9447f07edcdecc10543ca1fbdb46 to your computer and use it in GitHub Desktop.
"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.rdsUtils = {
toJsonObject(serializedSQLResult) {
const value = JSON.parse(serializedSQLResult);
const results = value.sqlStatementResults;
const rs = results.map((result) => {
const { records, columnMetadata } = result;
const items = records.map((record) => {
const r = {};
record.forEach((column, index) => {
const columnMap = column.toJSON();
for (const key in columnMap) {
const v = columnMap[key];
r[columnMetadata[index].name] = v;
}
})
return r;
});
return items;
});
console.log('-- toJsonObject', rs);
return rs;
},
toJsonString(value) {
return JSON.stringify(this.toJsonObject(value));
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment