Skip to content

Commit 10d6b60

Browse files
authored
chore(shell-api): show warning when connection is not mongos MONGOSH-1328 (#2097)
* show error when connection is not mongos * warn when user is not connected to mongos
1 parent 3bf0025 commit 10d6b60

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

packages/shell-api/src/collection.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import {
4242
buildConfigChunksCollectionMatch,
4343
onlyShardedCollectionsInConfigFilter,
4444
aggregateBackgroundOptionNotSupportedHelp,
45+
getConfigDB,
4546
} from './helpers';
4647
import type {
4748
AnyBulkWriteOperation,
@@ -2076,6 +2077,8 @@ export default class Collection extends ShellApiWithMongoClass {
20762077
async getShardDistribution(): Promise<CommandResult> {
20772078
this._emitCollectionApiCall('getShardDistribution', {});
20782079

2080+
await getConfigDB(this._database); // Warns if not connected to mongos
2081+
20792082
const result = {} as Document;
20802083
const config = this._mongo.getDB('config');
20812084
const ns = `${this._database._name}.${this._name}`;

0 commit comments

Comments
 (0)