-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
script to soft delet TSR hub documents
- Loading branch information
per305
authored and
per305
committed
Apr 29, 2022
1 parent
547940e
commit 1d2a854
Showing
1 changed file
with
15 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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}) | ||
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
var documents = db.document.find({"projectId":{$in:projectIdArr}}) | ||
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
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) | ||
print(documentId+", "+filepath); | ||
} |
print how many documents were modified as result of this operation. and compare with the below find query result.