Created
March 17, 2020 04:17
-
-
Save phanviet/a8776c34dd52866bc02caff21d9dd77c 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
export const rdsUtils = { | |
toJsonObject(value) { | |
const results = value.sqlStatementResults; | |
const rs = []; | |
results.forEach((result) => { | |
const { records, columnMetadata } = result; | |
const items = []; | |
records.forEach((record) => { | |
const r = {}; | |
let index = 0; | |
record.forEach((column) => { | |
const columnMap = column.toJSON(); | |
for (const key in columnMap) { | |
const v = columnMap[key]; | |
r[columnMetadata[index].name] = v; | |
} | |
index++; | |
}) | |
items.push(r); | |
}); | |
rs.push(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