Module: Mongoid::Sharding::ClassMethods

Defined in:
lib/mongoid/sharding.rb

Overview

:nodoc

Instance Method Summary collapse

Instance Method Details

#shard_key(*names) ⇒ Object

Specifies a shard key with the field(s) specified.

Examples:

Specify the shard key.


class Person
  include Mongoid::Document
  field :first_name, :type => String
  field :last_name, :type => String

  shard_key :first_name, :last_name
end

Since:

  • 2.0.0



46
47
48
# File 'lib/mongoid/sharding.rb', line 46

def shard_key(*names)
  self.shard_key_fields = names
end