mirror of
https://github.com/typicode/json-server.git
synced 2025-07-29 21:23:41 +08:00
refactor: update lowdb and lodash
This commit is contained in:
@ -136,8 +136,12 @@ module.exports = function (argv) {
|
||||
if (chunk.trim().toLowerCase() === 's') {
|
||||
var filename = 'db-' + Date.now() + '.json'
|
||||
var file = path.join(argv.snapshots, filename)
|
||||
app.db.saveSync(file)
|
||||
console.log(' Saved snapshot to ' + path.relative(process.cwd(), file) + '\n')
|
||||
app
|
||||
.db
|
||||
.write(file)
|
||||
.then(function () {
|
||||
console.log(' Saved snapshot to ' + path.relative(process.cwd(), file) + '\n')
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
var path = require('path')
|
||||
var got = require('got')
|
||||
var low = require('lowdb')
|
||||
var fileAsync = require('lowdb/lib/file-async')
|
||||
var is = require('./is')
|
||||
|
||||
module.exports = function (source, cb) {
|
||||
@ -27,7 +28,7 @@ module.exports = function (source, cb) {
|
||||
|
||||
} else if (is.JSON(source)) {
|
||||
|
||||
data = low(source).object
|
||||
data = low(source, { storage: fileAsync }).object
|
||||
cb(null, data)
|
||||
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user