Sha256: 67da28a2ce158b10cfa8f452b5af77744e2594454a4d3a38da9c619fd967d837
Contents?: true
Size: 797 Bytes
Versions: 6
Compression:
Stored size: 797 Bytes
Contents
# encoding: utf-8 module Mongoid #:nodoc module Indexes #:nodoc extend ActiveSupport::Concern included do cattr_accessor :indexed self.indexed = false end module ClassMethods #:nodoc # Add the default indexes to the root document if they do not already # exist. Currently this is only _type. def add_indexes if hereditary && !indexed self._collection.create_index(:_type, :unique => false, :background => true) self.indexed = true end end # Adds an index on the field specified. Options can be :unique => true or # :unique => false. It will default to the latter. def index(name, options = { :unique => false }) collection.create_index(name, options) end end end end
Version data entries
6 entries across 6 versions & 3 rubygems