<commit_before>************************
Collection Configuration
************************

.. default-domain:: mongodb

.. contents:: On this page
   :local:
   :backlinks: none
   :depth: 2
   :class: singlecol


Capped Collections
------------------

Mongoid does not provide a mechanism for creating capped collections on the fly - you
will need to create these yourself one time up front either with the driver or via the
Mongo console.

To create a capped collection with the driver:

.. code-block:: ruby

  client["name", :capped => true, :size => 1024].create

To create a capped collection from the Mongo console:

.. code-block:: javascript

  db.createCollection("name", { capped: true, size: 1024 });


Set a Default Collation on a Collection
---------------------------------------

Mongoid does not provide a mechanism for creating a collection with a default collation.
Like capped collections, you will need to create the collection yourself one time, up-front,
either with the driver or via the Mongo console.
<commit_msg>MONGOID-4834 Capped collection documentation examples lack setup/context (#5337)<commit_after>************************
Collection Configuration
************************

.. default-domain:: mongodb

.. contents:: On this page
   :local:
   :backlinks: none
   :depth: 2
   :class: singlecol


Capped Collections
------------------

Mongoid does not provide a mechanism for creating capped collections on the fly - you
will need to create these yourself one time up front either with the driver or via the
Mongo console.

To create a capped collection with the driver, first retrieve the client:

.. code-block:: ruby

  class Name
    include Mongoid::Document
  end
  client = Name.collection.client

Then create the collection:

.. code-block:: ruby

  client["names", :capped => true, :size => 1024].create

To create a capped collection from the Mongo console:

.. code-block:: javascript

  db.createCollection("name", { capped: true, size: 1024 });


Set a Default Collation on a Collection
---------------------------------------

Mongoid does not provide a mechanism for creating a collection with a default collation.
Like capped collections, you will need to create the collection yourself one time, up-front,
either with the driver or via the Mongo console.

{'fraction_non_alphanumeric': 0.1546793760831889, 'fraction_numerical': 0.011265164644714038, 'mean_word_length': 3.3320825515947465, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1876324', 'n_tokens_mistral': 612, 'n_tokens_neox': 548, 'n_words': 276}