Skip to content

Commit 2e865c4

Browse files
committed
Merge pull request #513
2 parents ac037c5 + 4200852 commit 2e865c4

5 files changed

+118
-1
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
source:
2+
file: apiargs-common-option.yaml
3+
ref: session
4+
---
5+
source:
6+
file: apiargs-MongoDBDatabase-common-option.yaml
7+
ref: typeMap
8+
post: |
9+
This will be used for the returned command result document.
10+
---
11+
source:
12+
file: apiargs-MongoDBDatabase-common-option.yaml
13+
ref: writeConcern
14+
...
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
source:
2+
file: apiargs-common-param.yaml
3+
ref: $collectionName
4+
replacement:
5+
subject: "collection or view"
6+
action: " to modify"
7+
---
8+
arg_name: param
9+
name: $collectionOptions
10+
type: array
11+
description: |
12+
Collection or view options to assign.
13+
interface: phpmethod
14+
operation: ~
15+
optional: false
16+
---
17+
source:
18+
file: apiargs-common-param.yaml
19+
ref: $options
20+
...

source/includes/apiargs-common-param.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,12 @@ arg_name: param
2323
name: $collectionName
2424
type: string
2525
description: |
26-
The name of the collection{{action}}.
26+
The name of the {{subject}}{{action}}.
2727
interface: phpmethod
2828
operation: ~
2929
optional: false
3030
replacement:
31+
subject: "collection"
3132
action: ""
3233
---
3334
arg_name: param

source/reference/class/MongoDBDatabase.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ Methods
5656
/reference/method/MongoDBDatabase-getTypeMap
5757
/reference/method/MongoDBDatabase-getWriteConcern
5858
/reference/method/MongoDBDatabase-listCollections
59+
/reference/method/MongoDBDatabase-modifyCollection
5960
/reference/method/MongoDBDatabase-selectCollection
6061
/reference/method/MongoDBDatabase-selectGridFSBucket
6162
/reference/method/MongoDBDatabase-withOptions
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
=====================================
2+
MongoDB\\Database::modifyCollection()
3+
=====================================
4+
5+
.. versionadded:: 1.4
6+
7+
.. default-domain:: mongodb
8+
9+
.. contents:: On this page
10+
:local:
11+
:backlinks: none
12+
:depth: 1
13+
:class: singlecol
14+
15+
Definition
16+
----------
17+
18+
.. phpmethod:: MongoDB\\Database::modifyCollection()
19+
20+
Modifies a collection or view according to the specified
21+
``$collectionOptions``.
22+
23+
.. code-block:: php
24+
25+
function modifyCollection($collectionName, array $collectionOptions, array $options = []): array|object
26+
27+
This method has the following parameters:
28+
29+
.. include:: /includes/apiargs/MongoDBDatabase-method-modifyCollection-param.rst
30+
31+
The ``$options`` parameter supports the following options:
32+
33+
.. include:: /includes/apiargs/MongoDBDatabase-method-modifyCollection-option.rst
34+
35+
Return Values
36+
-------------
37+
38+
An array or object with the result document of the :manual:`collMod
39+
</reference/command/collMod>` command.
40+
41+
Errors/Exceptions
42+
-----------------
43+
44+
.. include:: /includes/extracts/error-invalidargumentexception.rst
45+
.. include:: /includes/extracts/error-driver-runtimeexception.rst
46+
47+
Example
48+
-------
49+
50+
The following example changes the expiration time of a TTL collection in the
51+
``test`` database:
52+
53+
.. code-block:: php
54+
55+
<?php
56+
57+
$db = (new MongoDB\Client)->test;
58+
59+
$result = $db->modifyCollection('users', [
60+
'keyPattern' => ['lastAccess' => 1],
61+
'expireAfterSeconds' => 1000
62+
]);
63+
64+
var_dump($result);
65+
66+
The output would then resemble::
67+
68+
object(stdClass)#2779 {
69+
["expireAfterSeconds_old"]=>
70+
int(3)
71+
["expireAfterSeconds_new"]=>
72+
int(1000)
73+
["ok"]=>
74+
float(1)
75+
}
76+
77+
See Also
78+
--------
79+
80+
- :manual:`collMod </reference/command/collMod>` command reference in the MongoDB
81+
manual

0 commit comments

Comments
 (0)