Skip to content

Commit

Permalink
chore(shell-api): show warning when connection is not mongos MONGOSH-…
Browse files Browse the repository at this point in the history
…1328 (#2097)

* show error when connection is not mongos

* warn when user is not connected to mongos
  • Loading branch information
mabaasit authored Jul 29, 2024
1 parent 3bf0025 commit 10d6b60
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/shell-api/src/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import {
buildConfigChunksCollectionMatch,
onlyShardedCollectionsInConfigFilter,
aggregateBackgroundOptionNotSupportedHelp,
getConfigDB,
} from './helpers';
import type {
AnyBulkWriteOperation,
Expand Down Expand Up @@ -2076,6 +2077,8 @@ export default class Collection extends ShellApiWithMongoClass {
async getShardDistribution(): Promise<CommandResult> {
this._emitCollectionApiCall('getShardDistribution', {});

await getConfigDB(this._database); // Warns if not connected to mongos

const result = {} as Document;
const config = this._mongo.getDB('config');
const ns = `${this._database._name}.${this._name}`;
Expand Down

0 comments on commit 10d6b60

Please sign in to comment.