- Reference >
- JavaScript Methods >
- sh.addShardTag()
sh.addShardTag()¶
-
sh.
addShardTag
(shard, tag)¶ New in version 2.2.
Parameters: - shard (string) – Specifies the name of the shard that you want to give a specific tag.
- tag (string) – Specifies the name of the tag that you want to add to the shard.
sh.addShardTag()
associates a shard with a tag or identifier. MongoDB uses these identifiers to direct chunks that fall within a tagged range to specific shards.sh.addTagRange()
associates chunk ranges with tag ranges.Always issue
sh.addShardTag()
when connected to amongos
instance.Example
The following example adds three tags,
NYC
,LAX
, andNRT
, to three shards:See also