@@ -7,22 +7,22 @@ import { readDump } from './read-dump.js';
77import type { CollectionDiff , CollectionIndexes , CompareOptions , DatabaseDiff , DatabaseIndexes , DbMapRaw , FullDiff } from './types.js' ;
88import { getTargetToDumpDb } from './utils.js' ;
99
10- const compareCollections = ( desired : CollectionIndexes , actual ?: CollectionIndexes , dbMap ?: DbMapRaw ) : CollectionDiff => {
10+ const compareCollections = ( desired : CollectionIndexes , actual ?: CollectionIndexes , dbMap ?: DbMapRaw , options ?: CompareOptions ) : CollectionDiff => {
1111 const dumpDbName = getTargetToDumpDb ( dbMap ) . get ( desired . databaseName ) ?? desired . databaseName ;
1212
1313 const missingIndexes = desired . indexes . filter ( ( desiredIndex ) => {
1414 // Skip indexes that should be ignored in the dump
15- if ( shouldIgnoreIndexInDump ( dumpDbName , desired . collectionName , desiredIndex ) ) return false ;
15+ if ( shouldIgnoreIndexInDump ( dumpDbName , desired . collectionName , desiredIndex , options ) ) return false ;
1616
17- const match = actual ?. indexes . find ( actualIndex => isIndexEqual ( desiredIndex , actualIndex ) ) ;
17+ const match = actual ?. indexes . find ( actualIndex => isIndexEqual ( desiredIndex , actualIndex , options ) ) ;
1818 return ! match ;
1919 } ) ;
2020
2121 const extraIndexes = actual ?. indexes . filter ( ( actualIndex ) => {
2222 // Skip indexes that should be ignored in the target
23- if ( shouldIgnoreIndexInTarget ( dumpDbName , actual . collectionName , actualIndex ) ) return false ;
23+ if ( shouldIgnoreIndexInTarget ( dumpDbName , actual . collectionName , actualIndex , options ) ) return false ;
2424
25- const match = desired . indexes . find ( desiredIndex => isIndexEqual ( desiredIndex , actualIndex ) ) ;
25+ const match = desired . indexes . find ( desiredIndex => isIndexEqual ( desiredIndex , actualIndex , options ) ) ;
2626 return ! match ;
2727 } ) ;
2828
@@ -33,12 +33,12 @@ const compareCollections = (desired: CollectionIndexes, actual?: CollectionIndex
3333 } ;
3434} ;
3535
36- const compareDatabases = ( desired : DatabaseIndexes , actual ?: DatabaseIndexes , dbMap ?: DbMapRaw ) : DatabaseDiff => {
36+ const compareDatabases = ( desired : DatabaseIndexes , actual ?: DatabaseIndexes , dbMap ?: DbMapRaw , options ?: CompareOptions ) : DatabaseDiff => {
3737 const dbDiff : DatabaseDiff = { databaseName : desired . databaseName , collections : { } } ;
3838
3939 for ( const desiredCol of desired . collections ) {
4040 const actualCol = actual ?. collections . find ( actuaCol => actuaCol . collectionName === desiredCol . collectionName ) ;
41- const collectionResult = compareCollections ( desiredCol , actualCol , dbMap ) ;
41+ const collectionResult = compareCollections ( desiredCol , actualCol , dbMap , options ) ;
4242 if ( collectionResult . missingIndexes || collectionResult . extraIndexes ) {
4343 dbDiff . collections [ desiredCol . collectionName ] = collectionResult ;
4444 }
@@ -56,7 +56,7 @@ export const compareDump = async (options: CompareOptions): Promise<FullDiff> =>
5656 const diff : FullDiff = { databases : { } } ;
5757 for ( const desiredDb of desired ) {
5858 const actualDb = actual . find ( db => db . databaseName === desiredDb . databaseName ) ;
59- const dbDiff = compareDatabases ( desiredDb , actualDb , dbMap ) ;
59+ const dbDiff = compareDatabases ( desiredDb , actualDb , dbMap , options ) ;
6060 if ( Object . keys ( dbDiff . collections ) . length !== 0 ) {
6161 diff . databases [ desiredDb . databaseName ] = dbDiff ;
6262 }
0 commit comments