the code is as follows
const File = require("../lib/file").File
const path = require("path")
const fs = require("fs")
let handleFile = {
//
create (file) {
return File.create(file)
},
// id
getFileById (id) {
return File
.findOne({ _id: id })
// .addCreatedAt()
.exec()
},
}
// id
handleFile.deleteFileById = function async (id) {
let fileObject = await handleFile.getFileById(id)
fs.unlink(path.join("../uploads",fileObject.filename))
return File
.remove({ _id: id })
.exec()
}
//
// fileOperate.getFilePath = function async (id) {
// let fileObject = await file_operate.getFileById(id)
// return path.join("../uploads",fileObject.filename)
// }
module.exports = handleFile
screenshots of the error report are as follows
nodejs version 8.9.3 async/await can be used normally