Module: Mongoid::CollectionConfigurable::ClassMethods

Defined in:
lib/mongoid/collection_configurable.rb

Instance Method Summary collapse

Instance Method Details

#create_collection(force: false) ⇒ Object

Create the collection for the called upon Mongoid model.

This method does not re-create existing collections.

If the document includes store_in macro with collection_options key, these options are used when creating the collection.

Parameters:

  • force (true | false) (defaults to: false)

    If true, the method will drop existing collections before creating new ones. If false, the method will create only new collection (that do not exist in the database).

Raises:



22
23
24
25
26
# File 'lib/mongoid/collection_configurable.rb', line 22

def create_collection(force: false)
  Threaded.with_collection_management do
    perform_create_collection(force: force)
  end
end