From c2dfa320e525b72011ac10c68b4d34628d2d5920 Mon Sep 17 00:00:00 2001 From: Jamis Buck Date: Tue, 28 Mar 2023 09:48:30 -0600 Subject: [PATCH] Update sharding docs re: keys with "." characters in them --- docs/reference/sharding.txt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docs/reference/sharding.txt b/docs/reference/sharding.txt index 77e7d457e5..ab451bf4af 100644 --- a/docs/reference/sharding.txt +++ b/docs/reference/sharding.txt @@ -83,6 +83,21 @@ configured in the association as the field name: index country: 1 end +The shard key may also reference a field in an embedded document, by using +the "." character to delimit the field names: + +.. code-block:: ruby + + shard_key "location.x" => 1, "location.y" => 1 + + shard_key "location.x", "location.y" + +.. note:: + + Because the "." character is used to delimit fields in embedded documents, + Mongoid does not currently support shard key fields that themselves + literally contain the "." character. + .. note:: If a model declares a shard key, Mongoid expects the respective collection