diff --git a/scripts/RestClient/nesp/cleanNespDocuments.js b/scripts/RestClient/nesp/cleanNespDocuments.js index 5d311721c..92a8f9bf7 100644 --- a/scripts/RestClient/nesp/cleanNespDocuments.js +++ b/scripts/RestClient/nesp/cleanNespDocuments.js @@ -1,39 +1,26 @@ -var projectIdArr = ['c713e4f1-c57f-4040-9093-24f9aed39ac5','17e82227-aee5-4fbf-adaa-50a0469847e7'] +// This script will soft delete existing NESP TSR hub's documents + +var projectIdArr = ['d748bd95-0b4d-450c-8fa4-20a7bcfd9c19','08e07841-764c-4fcd-8bbc-7dc38e6fbd5f'] db.document.update({$and:[{"projectId": {$in: projectIdArr}},{"contentType": "application/pdf"}]},{$set:{"status": "deleted"}},{multi: true}) var documents = db.document.find({"projectId":{$in:projectIdArr}}) -var document = "" -var projectId = "" -var documentId = "" -var path = "" -var record = "" +var doc = ""; +var documentId = ""; +var filepath = ""; +var filename = ""; -var rows = [] +print("DOCUMENT ID, FULL PATH"); while (documents.hasNext()) { - document = documents.next(); - - projectId = document.projectId; - documentId = document.documentId; - path = document.filepath; - - record = projectId + "," + documentId + "," + path - - rows.push(record) -} - -let csvContent = "data:text/csv;charset=utf-8,"; - -rows.forEach(function(row) { - csvContent += row.join(','); - csvContent += "\n"; -}); + filepath = "/data/ecodata/uploads/" -console.log(csvContent); + doc = documents.next(); -var encodedUri = encodeURI(csvContent); -window.open(encodedUri); + documentId = doc.documentId; + filename = doc.filename; + filepath += doc.filepath + "/" + filename; -print("documentResult"+documentResult) \ No newline at end of file + print(documentId+", "+filepath); +} \ No newline at end of file