yazid138 há 2 anos atrás
pai
commit
a1e78d27fa
1 ficheiros alterados com 2 adições e 4 exclusões
  1. 2 4
      controller/auto.controller.js

+ 2 - 4
controller/auto.controller.js

@@ -392,10 +392,8 @@ exports.backup = handleError(async (req, res) => {
     })(),
     (async () => {
       const path = 'backup/' + new Date().getTime() + '-chunk.json'
-      const chunk = await chunkModel.find()
-      fs.writeFile(path, JSON.stringify(chunk), () => {
-        console.log('berhasil')
-      })
+      const chunk = await chunkModel.find().lean()
+      fs.writeFileSync(path, chunk)
       // const { size } = fs.statSync(path)
       // const mimetype = 'application/json'
       // const buffer = fs.readFileSync(path)