Minor refactoring.
This commit is contained in:
parent
7c045c4750
commit
5f5008fca1
@ -1,13 +1,13 @@
|
|||||||
import low from 'lowdb'
|
import low from 'lowdb'
|
||||||
import fileAsync from 'lowdb/lib/storages/file-async'
|
import storage from 'lowdb/lib/storages/file-async'
|
||||||
|
|
||||||
// Start database using file-async storage
|
|
||||||
const db = low('db.json', {
|
const db = low('db.json', {
|
||||||
storage: fileAsync
|
storage
|
||||||
})
|
})
|
||||||
|
|
||||||
db.defaults({uploads: []})
|
db.defaults({
|
||||||
.write()
|
uploads: []
|
||||||
|
}).write()
|
||||||
|
|
||||||
const saveFile = file => {
|
const saveFile = file => {
|
||||||
return db.get('uploads')
|
return db.get('uploads')
|
||||||
@ -29,9 +29,7 @@ export default {
|
|||||||
Mutation: {
|
Mutation: {
|
||||||
singleUpload: (_, {file}) => saveFile(file),
|
singleUpload: (_, {file}) => saveFile(file),
|
||||||
multipleUpload (_, {files}) {
|
multipleUpload (_, {files}) {
|
||||||
return Promise.all(files.map((file) => {
|
return Promise.all(files.map(file => saveFile(file))).then(results => results)
|
||||||
return saveFile(file)
|
|
||||||
})).then(results => results)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user