@@ -357,22 +357,6 @@ def create_collection(self, name, codec_options=None,
357
357
creation. :class:`~pymongo.errors.CollectionInvalid` will be
358
358
raised if the collection already exists.
359
359
360
- Options should be passed as keyword arguments to this method. Supported
361
- options vary with MongoDB release. Some examples include:
362
-
363
- - ``size``: desired initial size for the collection (in
364
- bytes). For capped collections this size is the max
365
- size of the collection.
366
- - ``capped``: if True, this is a capped collection
367
- - ``max``: maximum number of objects if capped (optional)
368
- - ``timeseries``: a document specifying configuration options for
369
- timeseries collections
370
- - ``expireAfterSeconds``: the number of seconds after which a
371
- document in a timeseries collection expires
372
-
373
- See the MongoDB documentation for a full list of supported options by
374
- server version.
375
-
376
360
:Parameters:
377
361
- `name`: the name of the collection to create
378
362
- `codec_options` (optional): An instance of
@@ -395,7 +379,21 @@ def create_collection(self, name, codec_options=None,
395
379
- `session` (optional): a
396
380
:class:`~pymongo.client_session.ClientSession`.
397
381
- `**kwargs` (optional): additional keyword arguments will
398
- be passed as options for the create collection command
382
+ be passed as options for the `create collection command`_
383
+
384
+ All optional `create collection command`_ parameters should be passed
385
+ as keyword arguments to this method. Valid options include, but are not
386
+ limited to:
387
+
388
+ - ``size``: desired initial size for the collection (in
389
+ bytes). For capped collections this size is the max
390
+ size of the collection.
391
+ - ``capped``: if True, this is a capped collection
392
+ - ``max``: maximum number of objects if capped (optional)
393
+ - ``timeseries``: a document specifying configuration options for
394
+ timeseries collections
395
+ - ``expireAfterSeconds``: the number of seconds after which a
396
+ document in a timeseries collection expires
399
397
400
398
.. versionchanged:: 3.11
401
399
This method is now supported inside multi-document transactions
@@ -412,6 +410,9 @@ def create_collection(self, name, codec_options=None,
412
410
413
411
.. versionchanged:: 2.2
414
412
Removed deprecated argument: options
413
+
414
+ .. _create collection command:
415
+ https://docs.mongodb.com/manual/reference/command/create
415
416
"""
416
417
with self .__client ._tmp_session (session ) as s :
417
418
# Skip this check in a transaction where listCollections is not
@@ -476,21 +477,6 @@ def aggregate(self, pipeline, session=None, **kwargs):
476
477
for operation in cursor:
477
478
print(operation)
478
479
479
- All optional `aggregate command`_ parameters should be passed as
480
- keyword arguments to this method. Valid options include, but are not
481
- limited to:
482
-
483
- - `allowDiskUse` (bool): Enables writing to temporary files. When set
484
- to True, aggregation stages can write data to the _tmp subdirectory
485
- of the --dbpath directory. The default is False.
486
- - `maxTimeMS` (int): The maximum amount of time to allow the operation
487
- to run in milliseconds.
488
- - `batchSize` (int): The maximum number of documents to return per
489
- batch. Ignored if the connected mongod or mongos does not support
490
- returning aggregate results using a cursor.
491
- - `collation` (optional): An instance of
492
- :class:`~pymongo.collation.Collation`.
493
-
494
480
The :meth:`aggregate` method obeys the :attr:`read_preference` of this
495
481
:class:`Database`, except when ``$out`` or ``$merge`` are used, in
496
482
which case :attr:`~pymongo.read_preferences.ReadPreference.PRIMARY`
@@ -506,7 +492,27 @@ def aggregate(self, pipeline, session=None, **kwargs):
506
492
- `pipeline`: a list of aggregation pipeline stages
507
493
- `session` (optional): a
508
494
:class:`~pymongo.client_session.ClientSession`.
509
- - `**kwargs` (optional): See list of options above.
495
+ - `**kwargs` (optional): extra `aggregate command`_ parameters.
496
+
497
+ All optional `aggregate command`_ parameters should be passed as
498
+ keyword arguments to this method. Valid options include, but are not
499
+ limited to:
500
+
501
+ - `allowDiskUse` (bool): Enables writing to temporary files. When set
502
+ to True, aggregation stages can write data to the _tmp subdirectory
503
+ of the --dbpath directory. The default is False.
504
+ - `maxTimeMS` (int): The maximum amount of time to allow the operation
505
+ to run in milliseconds.
506
+ - `batchSize` (int): The maximum number of documents to return per
507
+ batch. Ignored if the connected mongod or mongos does not support
508
+ returning aggregate results using a cursor.
509
+ - `collation` (optional): An instance of
510
+ :class:`~pymongo.collation.Collation`.
511
+ - `let` (dict): A dict of parameter names and values. Values must be
512
+ constant or closed expressions that do not reference document
513
+ fields. Parameters can then be accessed as variables in an
514
+ aggregate expression context (e.g. ``"$$var"``). This option is
515
+ only supported on MongoDB >= 5.0.
510
516
511
517
:Returns:
512
518
A :class:`~pymongo.command_cursor.CommandCursor` over the result
0 commit comments