Pull apart settings module

This commit is contained in:
Julia Friesel
2018-09-13 19:05:06 +02:00
parent 3c1653bc8c
commit 88fc3cad09
10 changed files with 317 additions and 286 deletions
+3 -1
View File
@@ -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))