Use FileSync in jsonServer.router

This commit is contained in:
Rui Fortes
2018-06-05 20:08:56 +01:00
parent 4b36016e21
commit a0e55b8ecb

View File

@ -4,7 +4,7 @@ const _ = require('lodash')
const lodashId = require('lodash-id')
const low = require('lowdb')
const Memory = require('lowdb/adapters/Memory')
const FileAsync = require('lowdb/adapters/FileAsync')
const FileSync = require('lowdb/adapters/FileSync')
const bodyParser = require('../body-parser')
const validateData = require('./validate-data')
const plural = require('./plural')
@ -14,7 +14,7 @@ const mixins = require('../mixins')
module.exports = (db, opts = { foreignKeySuffix: 'Id' }) => {
if (typeof db === 'string') {
db = low(new FileAsync(db))
db = low(new FileSync(db))
} else if (!_.has(db, '__chain__') || !_.has(db, '__wrapped__')) {
db = low(new Memory()).setState(db)
}