Exporting date and auto id field, but not importing autocolumns when table is created.
This commit is contained in:
parent
6b13d2ceaa
commit
a6de5a4fa1
|
@ -75,6 +75,7 @@ exports.handleDataImport = async (appId, user, table, dataImport) => {
|
||||||
if (!dataImport || !dataImport.csvString) {
|
if (!dataImport || !dataImport.csvString) {
|
||||||
return table
|
return table
|
||||||
}
|
}
|
||||||
|
|
||||||
const db = new CouchDB(appId)
|
const db = new CouchDB(appId)
|
||||||
// Populate the table with rows imported from CSV in a bulk update
|
// Populate the table with rows imported from CSV in a bulk update
|
||||||
const data = await csvParser.transform({
|
const data = await csvParser.transform({
|
||||||
|
|
|
@ -5,6 +5,7 @@ const exporters = require("./exporters")
|
||||||
const { saveView, getView, getViews, deleteView } = require("./utils")
|
const { saveView, getView, getViews, deleteView } = require("./utils")
|
||||||
const { fetchView } = require("../row")
|
const { fetchView } = require("../row")
|
||||||
const { getTable } = require("../table/utils")
|
const { getTable } = require("../table/utils")
|
||||||
|
const { FieldTypes } = require("../../../constants")
|
||||||
|
|
||||||
exports.fetch = async ctx => {
|
exports.fetch = async ctx => {
|
||||||
const db = new CouchDB(ctx.appId)
|
const db = new CouchDB(ctx.appId)
|
||||||
|
@ -86,15 +87,15 @@ exports.exportView = async ctx => {
|
||||||
schema = table.schema
|
schema = table.schema
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove any auto columns
|
// remove any relationships
|
||||||
const autocolumns = Object.entries(schema)
|
const relationships = Object.entries(schema)
|
||||||
.filter(entry => entry[1].autocolumn)
|
.filter(entry => entry[1].type === FieldTypes.LINK)
|
||||||
.map(entry => entry[0])
|
.map(entry => entry[0])
|
||||||
rows.forEach(row => {
|
rows.forEach(row => {
|
||||||
autocolumns.forEach(column => delete row[column])
|
relationships.forEach(column => delete row[column])
|
||||||
})
|
})
|
||||||
// delete auto columns from schema
|
// delete relationships from schema
|
||||||
autocolumns.forEach(column => {
|
relationships.forEach(column => {
|
||||||
delete schema[column]
|
delete schema[column]
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -102,8 +102,11 @@ async function transform({ schema, csvString, existingTable }) {
|
||||||
schema = updateSchema({ schema, existingTable })
|
schema = updateSchema({ schema, existingTable })
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let key of Object.keys(schema)) {
|
for (let [key, field] of Object.entries(schema)) {
|
||||||
colParser[key] = PARSERS[schema[key].type] || schema[key].type
|
// don't import data to auto columns
|
||||||
|
if (!field.autocolumn) {
|
||||||
|
colParser[key] = PARSERS[field.type] || field.type
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue