-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #610 from jay-m-dev/197-delete-datasets
197 delete datasets
- Loading branch information
Showing
8 changed files
with
249 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const db = require("./db").db; | ||
|
||
async function deleteFilesFromGridstore(files) { | ||
try { | ||
let filesP = []; | ||
let filesDeleted = 0; | ||
|
||
for (let i = 0; i < files.length; i++) { | ||
let gfs = new db.GridStore(db, files[i]._id, 'w', { | ||
promiseLibrary: Promise | ||
}); | ||
filesP.push(gfs.unlinkAsync().then(() => { | ||
filesDeleted++; | ||
})); | ||
} | ||
|
||
await Promise.all(filesP); | ||
return filesDeleted; | ||
} catch (err) { | ||
console.log(err); | ||
throw err; | ||
} | ||
} | ||
|
||
module.exports = { | ||
deleteFilesFromGridstore | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.