Skip to content

Commit 58d03aa

Browse files
committed
Add documentation
1 parent 4aad357 commit 58d03aa

5 files changed

+119
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
source:
2+
file: apiargs-MongoDBCollection-common-option.yaml
3+
ref: typeMap
4+
post: |
5+
This will be used for the returned command result document.
6+
---
7+
source:
8+
file: apiargs-common-option.yaml
9+
ref: session
10+
post: |
11+
.. versionadded:: 1.3
12+
---
13+
source:
14+
file: apiargs-MongoDBCollection-common-option.yaml
15+
ref: writeConcern
16+
post: |
17+
This is not supported for server versions prior to 3.4 and will result in an
18+
exception at execution time if used.
19+
---
20+
source:
21+
file: apiargs-MongoDBCollection-common-option.yaml
22+
ref: dropTarget
23+
...
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
arg_name: param
2+
name: $newCollectionName
3+
type: string
4+
description: |
5+
The new name for this collection.
6+
interface: phpmethod
7+
operation: ~
8+
optional: false
9+
---
10+
source:
11+
file: apiargs-common-param.yaml
12+
ref: $options
13+
...

docs/reference/class/MongoDBCollection.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ Methods
9191
/reference/method/MongoDBCollection-insertOne
9292
/reference/method/MongoDBCollection-listIndexes
9393
/reference/method/MongoDBCollection-mapReduce
94+
/reference/method/MongoDBCollection-renameCollection
9495
/reference/method/MongoDBCollection-replaceOne
9596
/reference/method/MongoDBCollection-updateMany
9697
/reference/method/MongoDBCollection-updateOne

docs/reference/class/MongoDBDatabase.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ Methods
5959
/reference/method/MongoDBDatabase-listCollectionNames
6060
/reference/method/MongoDBDatabase-listCollections
6161
/reference/method/MongoDBDatabase-modifyCollection
62+
/reference/method/MongoDBDatabase-renameCollection
6263
/reference/method/MongoDBDatabase-selectCollection
6364
/reference/method/MongoDBDatabase-selectGridFSBucket
6465
/reference/method/MongoDBDatabase-watch
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
===========================
2+
MongoDB\\Collection::renameCollection()
3+
===========================
4+
5+
.. default-domain:: mongodb
6+
7+
.. contents:: On this page
8+
:local:
9+
:backlinks: none
10+
:depth: 1
11+
:class: singlecol
12+
13+
Definition
14+
----------
15+
16+
.. phpmethod:: MongoDB\\Collection::renameCollection()
17+
18+
Rename the collection.
19+
20+
.. code-block:: php
21+
22+
function renameCollection(string $newCollectionName, array $options = []): array|object
23+
24+
This method has the following parameters:
25+
26+
.. include:: /includes/apiargs/MongoDBCollection-method-renameCollection-param.rst
27+
28+
The ``$options`` parameter supports the following options:
29+
30+
.. include:: /includes/apiargs/MongoDBCollection-method-renameCollection-option.rst
31+
32+
Return Values
33+
-------------
34+
35+
An array or object with the result document of the :manual:`renameCollection
36+
</reference/command/renameCollection>` command. The return type will depend on the
37+
``typeMap`` option.
38+
39+
Errors/Exceptions
40+
-----------------
41+
42+
.. include:: /includes/extracts/error-unsupportedexception.rst
43+
.. include:: /includes/extracts/error-invalidargumentexception.rst
44+
.. include:: /includes/extracts/error-driver-runtimeexception.rst
45+
46+
Example
47+
-------
48+
49+
The following operation renames the ``restaurants`` collection in the ``admin``
50+
database to ``zips``:
51+
52+
.. code-block:: php
53+
54+
<?php
55+
56+
$collection = (new MongoDB\Client)->admin->restaurants;
57+
58+
$result = $collection->renameCollection('zips');
59+
60+
var_dump($result);
61+
62+
The output would then resemble::
63+
64+
object(MongoDB\Model\BSONDocument)#9 (1) {
65+
["storage":"ArrayObject":private]=>
66+
array(3) {
67+
["ns"]=>
68+
string(16) "test.restaurants"
69+
["nIndexesWas"]=>
70+
int(3)
71+
["ok"]=>
72+
float(1)
73+
}
74+
}
75+
76+
See Also
77+
--------
78+
79+
- :phpmethod:`MongoDB\\Database::renameCollection()`
80+
- :manual:`renameCollection </reference/command/renameCollection>` command reference in the MongoDB
81+
manual

0 commit comments

Comments
 (0)