Pull apart settings module
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import csvParser from 'csvtojson'
|
||||
import isObject from 'isobject'
|
||||
import { schema, tryToImportWithDelete, tryToImportWithoutDelete } from '../../db'
|
||||
import { getSchema, tryToImportWithDelete, tryToImportWithoutDelete } from '../../db'
|
||||
import getColumnNamesForCsv from './get-csv-column-names'
|
||||
|
||||
export default async function importCsv(csv, deleteFirst) {
|
||||
@@ -23,6 +23,7 @@ export default async function importCsv(csv, deleteFirst) {
|
||||
return Number(val)
|
||||
}
|
||||
|
||||
const schema = getSchema()
|
||||
const config = {
|
||||
ignoreEmpty: true,
|
||||
colParser: getColumnNamesForCsv().reduce((acc, colName) => {
|
||||
@@ -76,6 +77,7 @@ function putNullForEmptySymptoms(data) {
|
||||
}
|
||||
|
||||
function getDbType(modelProperties, path) {
|
||||
const schema = getSchema()
|
||||
if (path.length === 1) return modelProperties[path[0]].type
|
||||
const modelName = modelProperties[path[0]].objectType
|
||||
return getDbType(schema[modelName], path.slice(1))
|
||||
|
||||
Reference in New Issue
Block a user