diff --git a/source/databases-collections.txt b/source/databases-collections.txt index e75021b5..4cdf0a82 100644 --- a/source/databases-collections.txt +++ b/source/databases-collections.txt @@ -39,7 +39,7 @@ Access a Database Access a database by using dictionary-style access on your ``MongoClient`` instance. -The following example accesses a database named "test_database": +The following example accesses a database named ``test_database``: .. code-block:: python @@ -50,7 +50,7 @@ Access a Collection Access a collection by using dictionary-style access on an instance of your database. -The following example accesses a collection named "test_collection": +The following example accesses a collection named ``test_collection``: .. code-block:: python :emphasize-lines: 2 @@ -70,7 +70,7 @@ Create a Collection Use the ``create_collection()`` method to explicitly create a collection in a MongoDB database. -The following example creates a collection called ``"example_collection"``: +The following example creates a collection called ``example_collection``: .. code-block:: python :emphasize-lines: 2 @@ -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`` +in which the documents' time field is 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 +~~~~~~~~~~~~~~~~~ + +You can create a capped collection that cannot grow beyond a specified memory size or +document count. The following example creates a capped collection called +``example_capped_collection`` that has 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 :manual:`Capped Collections ` +in the {+mdb-server+} manual. + Get a List of Collections -------------------------