Commit 09166d3e authored by Katherine Walker's avatar Katherine Walker

Add modifyCollection documentation

parent 44f36ce3
source:
file: apiargs-common-option.yaml
ref: session
---
source:
file: apiargs-MongoDBDatabase-common-option.yaml
ref: typeMap
post: |
This will be used for the returned command result document.
---
source:
file: apiargs-MongoDBDatabase-common-option.yaml
ref: writeConcern
...
source:
file: apiargs-common-param.yaml
ref: $collectionName
replacement:
subject: "collection or view"
action: " to modify"
---
arg_name: param
name: $collectionOptions
type: array
description: |
Collection or view options to assign.
interface: phpmethod
operation: ~
optional: false
---
source:
file: apiargs-common-param.yaml
ref: $options
...
...@@ -23,11 +23,12 @@ arg_name: param ...@@ -23,11 +23,12 @@ arg_name: param
name: $collectionName name: $collectionName
type: string type: string
description: | description: |
The name of the collection{{action}}. The name of the {{subject}}{{action}}.
interface: phpmethod interface: phpmethod
operation: ~ operation: ~
optional: false optional: false
replacement: replacement:
subject: "collection"
action: "" action: ""
--- ---
arg_name: param arg_name: param
......
...@@ -56,6 +56,7 @@ Methods ...@@ -56,6 +56,7 @@ Methods
/reference/method/MongoDBDatabase-getTypeMap /reference/method/MongoDBDatabase-getTypeMap
/reference/method/MongoDBDatabase-getWriteConcern /reference/method/MongoDBDatabase-getWriteConcern
/reference/method/MongoDBDatabase-listCollections /reference/method/MongoDBDatabase-listCollections
/reference/method/MongoDBDatabase-modifyCollection
/reference/method/MongoDBDatabase-selectCollection /reference/method/MongoDBDatabase-selectCollection
/reference/method/MongoDBDatabase-selectGridFSBucket /reference/method/MongoDBDatabase-selectGridFSBucket
/reference/method/MongoDBDatabase-withOptions /reference/method/MongoDBDatabase-withOptions
......
=====================================
MongoDB\\Database::modifyCollection()
=====================================
.. versionadded:: 1.4
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. phpmethod:: MongoDB\\Database::modifyCollection()
Modifies a collection or view according to the specified
``$collectionOptions``.
.. code-block:: php
function modifyCollection($collectionName, array $collectionOptions, array $options = []): array|object
This method has the following parameters:
.. include:: /includes/apiargs/MongoDBDatabase-method-modifyCollection-param.rst
The ``$options`` parameter supports the following options:
.. include:: /includes/apiargs/MongoDBDatabase-method-modifyCollection-option.rst
Return Values
-------------
An array or object with the result document of the :manual:`collMod
</reference/command/collMod>` command.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
Example
-------
The following example changes the expiration time of a TTL collection in the
``test`` database:
.. code-block:: php
<?php
$db = (new MongoDB\Client)->test;
$result = $db->modifyCollection('users', [
'keyPattern' => ['lastAccess' => 1],
'expireAfterSeconds' => 1000
]);
var_dump($result);
The output would then resemble::
object(stdClass)#2779 {
["expireAfterSeconds_old"]=>
int(3)
["expireAfterSeconds_new"]=>
int(1000)
["ok"]=>
float(1)
}
See Also
--------
- :manual:`collMod </reference/command/collMod>` command reference in the MongoDB
manual
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment