@@ -39,7 +39,7 @@ Access a Database
39
39
40
40
Access a database by using dictionary-style access on your ``MongoClient`` instance.
41
41
42
- The following example accesses a database named " test_database" :
42
+ The following example accesses a database named `` test_database`` :
43
43
44
44
.. code-block:: python
45
45
@@ -50,7 +50,7 @@ Access a Collection
50
50
51
51
Access a collection by using dictionary-style access on an instance of your database.
52
52
53
- The following example accesses a collection named " test_collection" :
53
+ The following example accesses a collection named `` test_collection`` :
54
54
55
55
.. code-block:: python
56
56
:emphasize-lines: 2
@@ -70,7 +70,7 @@ Create a Collection
70
70
Use the ``create_collection()`` method to explicitly create a collection in a
71
71
MongoDB database.
72
72
73
- The following example creates a collection called ``" example_collection" ``:
73
+ The following example creates a collection called ``example_collection``:
74
74
75
75
.. code-block:: python
76
76
:emphasize-lines: 2
@@ -83,6 +83,36 @@ validation rules, by passing them in as keyword arguments. For a full list of
83
83
optional parameters, see the `create_collection() API documentation
84
84
<{+api-root+}pymongo/database.html#pymongo.database.Database.create_collection>`__.
85
85
86
+ Time Series Collection
87
+ ~~~~~~~~~~~~~~~~~~~~~~
88
+
89
+ Time series collections efficiently store sequences of measurements over a period of time.
90
+ The following example creates a time series collection called ``example_ts_collection``
91
+ in which the documents' time field is called ``timestamp``:
92
+
93
+ .. code-block:: python
94
+
95
+ database = client["test_database"]
96
+ database.create_collection("example_ts_collection", timeseries={"timeField": "timestamp"})
97
+
98
+ For more information about using time series data with {+driver-short+}, see the
99
+ :ref:`pymongo-time-series` guide.
100
+
101
+ Capped Collection
102
+ ~~~~~~~~~~~~~~~~~
103
+
104
+ You can create a capped collection that cannot grow beyond a specified memory size or
105
+ document count. The following example creates a capped collection called
106
+ ``example_capped_collection`` that has a maximum size of 1000 bytes:
107
+
108
+ .. code-block:: python
109
+
110
+ database = client["test_database"]
111
+ database.create_collection("example_capped_collection", capped=True, size=1000)
112
+
113
+ To learn more about capped collections, see :manual:`Capped Collections </core/capped-collections/>`
114
+ in the {+mdb-server+} manual.
115
+
86
116
Get a List of Collections
87
117
-------------------------
88
118
0 commit comments