Module: Mongoid::Sharding

Extended by:
ActiveSupport::Concern
Included in:
Components
Defined in:
lib/mongoid/sharding.rb

Overview

This module contains behaviour for adding shard key fields to updates.

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#shard_key_selectorHash

Get the document selector with the defined shard keys.

Examples:

Get the selector for the shard keys.

person.shard_key_selector

Returns:

  • (Hash)

    The shard key selector.

Since:

  • 2.0.0



23
24
25
26
27
28
29
# File 'lib/mongoid/sharding.rb', line 23

def shard_key_selector
  {}.tap do |selector|
    shard_key_fields.each do |field|
      selector[field.to_s] = send(field)
    end
  end
end