'Running mongo shell script using kubernetes job
I need to create kubernetes job that will run below script on mongo shell:
var operations = [];
db.product.find().forEach(function(doc) {
var documentLink = doc.documentLink;
var operation = { updateMany :{
"filter" : {"_id" : doc._id},
"update" : {$set:{"documentLinkMap.en":documentLink,"documentLinkMap.de":""},
$unset: {documentLink:"","descriptionMap.tr":"","news.tr":"","descriptionInternal.tr":"","salesDescription.tr":"","salesInternal.tr":"","deliveryDescription.tr":"","deliveryInternal.tr":"","productRoadMapDescription.tr":"","productRoadMapInternal.tr":"","technicalsAndIntegration.tr":"","technicalsAndIntegrationInternal.tr":"","versions.$[].descriptionMap.tr":"","versions.$[].releaseNoteMap.tr":"","versions.$[].artifacts.$[].descriptionMap.tr":"","versions.$[].artifacts.$[].artifactNotes.tr":""}}}};
operations.push(operation);
});
operations.push( {
ordered: true,
writeConcern: { w: "majority", wtimeout: 5000 }
});
db.product.bulkWrite(operations);
I will need a sample of how that job will look like. Should I create presistent volume and claim to it or is there possibility to run this job without persistent volume? I need to run this once and then remove it.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
