MCPcopy
hub / github.com/beekeeper-studio/beekeeper-studio / mapData

Method mapData

apps/studio/src/lib/import/index.ts:94–117  ·  view source on GitHub ↗

* * @param {Object[]} data a JSON object of the data to be mapped * @returns {Object[]} An array of objects of the data

(data)

Source from the content-addressed store, hash-verified

92 * @returns {Object[]} An array of objects of the data
93 */
94 mapData (data) {
95 return data.map(d =>
96 this.options.importMap.reduce((acc, m) => {
97 const columnData = d[m.fileColumn]
98 let importedValue = null
99
100 if (columnData != null) {
101 if (this.options.trimWhitespaces && _.isString(columnData)) {
102 importedValue = columnData.trim()
103 } else if (_.isString(columnData)) {
104 importedValue = columnData
105 } else {
106 importedValue = columnData
107 }
108
109 if (this.options.nullableValues.includes(importedValue.toString().toUpperCase().trim())) {
110 importedValue = null
111 }
112 }
113 acc[m.tableColumn] = importedValue
114 return acc
115 }, {})
116 )
117 }
118
119 /**
120 * Take the data to be put into the table and format it for the insertQueryBuilder function in client

Callers 3

buildDataObjMethod · 0.95
readMethod · 0.80
importHandlers.tsFile · 0.80

Calls 1

toStringMethod · 0.45

Tested by

no test coverage detected