@@ -430,8 +430,7 @@ export async function getPrintableShardStatus(configDB: Database, verbose: boole
430430 collRes . balancing = [ ! coll . noBalance , { noBalance : coll . noBalance } ] ;
431431 }
432432 const chunksRes = [ ] ;
433- const chunksCollMatch =
434- coll . uuid ? { $or : [ { uuid : coll . uuid } , { ns : coll . _id } ] } : { ns : coll . _id } ;
433+ const chunksCollMatch = buildConfigChunksCollectionMatch ( coll ) ;
435434 const chunks = await
436435 ( await chunksColl . aggregate ( [
437436 { $match : chunksCollMatch } ,
@@ -474,7 +473,9 @@ export async function getPrintableShardStatus(configDB: Database, verbose: boole
474473 }
475474
476475 const tagsRes : any [ ] = [ ] ;
477- for await ( const tag of ( await configDB . getCollection ( 'tags' ) . find ( chunksCollMatch ) ) . sort ( { min : 1 } ) ) {
476+ for await ( const tag of ( await configDB . getCollection ( 'tags' ) . find ( {
477+ ns : coll . _id
478+ } ) ) . sort ( { min : 1 } ) ) {
478479 tagsRes . push ( {
479480 tag : tag . tag ,
480481 min : tag . min ,
@@ -851,3 +852,13 @@ export function shallowClone<T>(input: T): T {
851852 if ( ! input || typeof input !== 'object' ) return input ;
852853 return Array . isArray ( input ) ? ( [ ...input ] as unknown as T ) : { ...input } ;
853854}
855+
856+ // Take a document from config.collections and return a corresponding match filter
857+ // for config.chunks.
858+ // https://jira.mongodb.org/browse/MONGOSH-1179
859+ // https://github.com/mongodb/mongo/commit/aeb430b26171d5afc55f1278a29cc0f998f6a4e1
860+ export function buildConfigChunksCollectionMatch ( configCollectionsInfo : Document ) : Document {
861+ return Object . prototype . hasOwnProperty . call ( configCollectionsInfo , 'timestamp' ) ?
862+ { uuid : configCollectionsInfo . uuid } : // new format
863+ { ns : configCollectionsInfo . _id } ; // old format
864+ }
0 commit comments