Docs Menu

sh.isConfigShardEnabled()

sh.isConfigShardEnabled()

The sh.isConfigShardEnabled() method returns whether a cluster has a config shard. If it does, then sh.isConfigShardEnabled() also returns the config shard's host and tag information.

sh.isConfigShardEnabled() has the following syntax:

sh.isConfigShardEnabled()

sh.isConfigShardEnabled() returns a document that contains the following fields:

{
enabled: <boolean>,
host: <string>,
tags: [<string>]
}
Field
Type
Description

enabled

boolean

true if the cluster has a config shard, false if it does not.

host

string

Hostname of config shard. Only present if enabled is true.

tags

array of strings

List of zones to which the shard belongs.

The following example shows how to run sh.isConfigShardEnabled(). It shows the output when you run the method on a cluster that has a config shard, but this shard does not have any associated tags:

sh.isConfigShardEnabled()
{ enabled: true, host: 'shard3/localhost:27017' }

The following example shows the output if you run sh.isConfigShardEnabled() on a cluster that has a config shard with associated tags:

{
enabled: true,
host: 'shard3/localhost:27017',
tags: ['tag1', 'tag2']
}