sh.moveRange()
定義
sh.moveRange(namespace, toShard, min, max)
バージョン 6.0 で追加。
重要
mongosh メソッド
このページでは、
mongosh
メソッドについて記載しています。ただし、データベースコマンドや Node.js などの言語固有のドライバーのドキュメントには該当しません。データベースコマンドについては、
moveRange
コマンドを参照してください。MongoDB API ドライバーについては、各言語の MongoDB ドライバー ドキュメントを参照してください。
互換性
このコマンドは、次の環境でホストされている配置で使用できます。
MongoDB Atlas はクラウドでの MongoDB 配置のためのフルマネージド サービスです
注意
このコマンドは、すべての MongoDB Atlas クラスターでサポートされています。すべてのコマンドに対する Atlas のサポートについては、「サポートされていないコマンド」を参照してください。
MongoDB Enterprise: サブスクリプションベースの自己管理型 MongoDB バージョン
MongoDB Community: ソースが利用可能で、無料で使用できる自己管理型の MongoDB のバージョン
構文
sh.moveRange(namespace, toShard, min, max)
The sh.moveRange()
method takes the following parameters:
Parameter | タイプ | 説明 |
---|---|---|
| string | Sets the database and collection of the range to move. |
| string | Sets the ID of the shard to receive the range. |
| ドキュメント | 移動する範囲の最小キー。 |
| ドキュメント | Maximum key of the range to move. |
例
The following example uses a collection with:
Shard key
postal
, representing a postal code.A range with the boundaries
70007
and70124
.
To move the postal range to shard02
, run the following
method:
sh.moveRange( "contacts.addresses", "shard02", { postal: 70007 }, { postal: 70124 } )
{ ok: 1, '$clusterTime': { clusterTime: Timestamp({ t: 1742507819, i: 42 }), signature: { hash: Binary.createFromBase64('AAAAAAAAAAAAAAAAAAAAAAAAAAA=', 0), keyId: Long('0') } }, operationTime: Timestamp({ t: 1742507819, i: 42 }) }