Skip to content

Commit

Permalink
fix settings init error
Browse files Browse the repository at this point in the history
  • Loading branch information
david-loe committed Aug 16, 2024
1 parent 8a69126 commit d7479f1
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions backend/db.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import axios from 'axios'
import mongoose, { Model } from 'mongoose'
import { mergeDeep } from '../common/scripts.js'
import { CountryLumpSum, Settings as ISettings } from '../common/types.js'
import countries from './data/countries.json' assert { type: 'json' }
import currencies from './data/currencies.json' assert { type: 'json' }
Expand All @@ -11,8 +12,6 @@ import Currency from './models/currency.js'
import HealthInsurance from './models/healthInsurance.js'
import Organisation from './models/organisation.js'
import Project from './models/project.js'
import { mergeDeep } from '../common/scripts.js'
import { getSettings } from './helper.js'

export async function connectDB() {
const first = mongoose.connection.readyState === 0
Expand All @@ -30,7 +29,7 @@ export function disconnectDB() {
}

export async function initDB() {
const DBsettings = await getSettings()
const DBsettings = (await mongoose.connection.collection('settings').findOne()) as ISettings | null
if (DBsettings) {
if (DBsettings.version !== settings.version) {
DBsettings.migrateFrom = DBsettings.version
Expand Down

0 comments on commit d7479f1

Please sign in to comment.