MongoDB-এ প্যাটার্ন ম্যাচ করে একাধিক কলেকশন একসাথে ড্রপ করতে লুপ এবং drop() মেথড ব্যবহার করা হয়।
ডেটাবেস এবং কলেকশন লিস্ট
arraySizeErrorDemo basicInformationDemo copyThisCollectionToSampleDatabaseDemo deleteAllRecordsDemo deleteDocuments deleteDocumentsDemo deleteMultipleIdsDemo deleteSomeInformation documentWithAParticularFieldValueDemo employee findListOfIdsDemo findMimimumElementInArrayDemo findSubstring getAllRecordsFromSourceCollectionDemo getElementWithMaxIdDemo insertDocumentWithDateDemo internalArraySizeDemo largestDocumentDemo makingStudentInformationClone oppositeAddToSetDemo prettyDemo returnOnlyUniqueValuesDemo selectWhereInDemo sourceCollection studentInformation sumOfValueDemo sumTwoFieldsDemo truncateDemo updateInformation userInformation
"delete" দিয়ে শুরু হওয়া কলেকশন ড্রপ করার স্ক্রিপ্ট
True
ডিলিট করার পর কলেকশন লিস্ট
arraySizeErrorDemo basicInformationDemo copyThisCollectionToSampleDatabaseDemo documentWithAParticularFieldValueDemo employee findListOfIdsDemo findMimimumElementInArrayDemo findSubstring getAllRecordsFromSourceCollectionDemo getElementWithMaxIdDemo insertDocumentWithDateDemo internalArraySizeDemo largestDocumentDemo makingStudentInformationClone oppositeAddToSetDemo prettyDemo returnOnlyUniqueValuesDemo selectWhereInDemo sourceCollection studentInformation sumOfValueDemo sumTwoFieldsDemo truncateDemo updateInformation userInformation
কোড ব্যাখ্যা
db.getCollectionNames()- সকল কলেকশন নাম আনেindexOf('delete') == 0- "delete" দিয়ে শুরু হয় কিনা চেক করেdb[colName].drop()- কলেকশন ড্রপ করে- ব্র্যাকেট নোটেশন
db[colName]ডাইনামিক কলেকশন এক্সেসের জন্য
সাবধানতা
- অপারেশন অন-ডゥ নয় - একবার ড্রপ হলে রিকভারি সম্ভব নয়
- প্রোডাকশনে চালানোর আগে ব্যাকআপ নিন
indexOfকেস-সেনসিটিভ