Skip to content

DOCSP-46688: Add collection configuration sections #161

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 3, 2025
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions source/databases-collections.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,36 @@ validation rules, by passing them in as keyword arguments. For a full list of
optional parameters, see the `create_collection() API documentation
<{+api-root+}pymongo/database.html#pymongo.database.Database.create_collection>`__.

Time Series Collection
~~~~~~~~~~~~~~~~~~~~~~

Time series collections efficiently store sequences of measurements over a period of time.
The following example creates a time series collection called ``"example_ts_collection"``
with a time field called ``"timestamp"``:

.. code-block:: python

database = client["test_database"]
database.create_collection("example_ts_collection", timeseries={"timeField": "timestamp"})

For more information about using time series data with {+driver-short+}, see the
:ref:`<pymongo-time-series>` guide.

Capped Collection
~~~~~~~~~~~~~~~~~

Capped collections have a maximum size that prevent them from growing beyond a specified
limit. The following example creates a capped collection called ``"example_capped_collection"``
with a maximum size of 1000 bytes:

.. code-block:: python

database = client["test_database"]
database.create_collection("example_capped_collection", capped=True, size=1000)

To learn more about capped collections, see the :manual:`Capped Collections </core/capped-collections/>`
guide in the {+mdb-server+} manual.

Get a List of Collections
-------------------------

Expand Down
Loading