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()
|
const collectionExists = existingCollections.has(collName);
|
||||||
.filter(idx => idx.name !== "_id_");
|
const existingIndexes = collectionExists
|
||||||
|
? targetDb.getCollection(collName).getIndexes().filter(idx => idx.name !== "_id_")
|
||||||
|
: [];
|
||||||
|
|
||||||
if (existingIndexes.length > 0) {
|
if (existingIndexes.length > 0) {
|
||||||
if (dryRun) {
|
if (dryRun) {
|
||||||
|
|||||||
Reference in New Issue
Block a user