Last active
March 17, 2020 04:46
-
-
Save phanviet/a52f9447f07edcdecc10543ca1fbdb46 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"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