Browse Source

fix: import csv issue

Signed-off-by: Wing-Kam Wong <wingkwong.code@gmail.com>
pull/1738/head
Wing-Kam Wong 3 years ago
parent
commit
ab3a4c5316
  1. 11
      packages/nc-gui/components/project/spreadsheet/components/moreActions.vue

11
packages/nc-gui/components/project/spreadsheet/components/moreActions.vue

@ -286,10 +286,6 @@ export default {
},
async importData(columnMappings) {
try {
const api = this.$ncApis.get({
table: this.meta.table_name
})
const data = this.parsedCsv.data
for (let i = 0, progress = 0; i < data.length; i += 500) {
const batchData = data.slice(i, i + 500).map(row => columnMappings.reduce((res, col) => {
@ -312,7 +308,12 @@ export default {
}
return res
}, {}))
await api.insertBulk(batchData)
await this.$api.dbTableRow.bulkCreate(
'noco',
this.projectName,
this.meta.title,
batchData
)
progress += batchData.length
this.$store.commit('loader/MutMessage', `Importing data : ${progress}/${data.length}`)
this.$store.commit('loader/MutProgress', Math.round((100 * progress / data.length)))

Loading…
Cancel
Save