You've already forked mongo-index-helper
fix: skip getIndexes() on non-existent collection during --dry-run
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -57,8 +57,10 @@ for (const [collName, indexes] of Object.entries(data)) {
|
||||
}
|
||||
}
|
||||
|
||||
const existingIndexes = targetDb.getCollection(collName).getIndexes()
|
||||
.filter(idx => idx.name !== "_id_");
|
||||
const collectionExists = existingCollections.has(collName);
|
||||
const existingIndexes = collectionExists
|
||||
? targetDb.getCollection(collName).getIndexes().filter(idx => idx.name !== "_id_")
|
||||
: [];
|
||||
|
||||
if (existingIndexes.length > 0) {
|
||||
if (dryRun) {
|
||||
|
||||
Reference in New Issue
Block a user