Skip to content

Commit e6e6456

Browse files
kevinadikay-kim
authored andcommitted
DOCS-7923 Update db.cloneCollection() example
Signed-off-by: kay <[email protected]>
1 parent c508b1b commit e6e6456

File tree

4 files changed

+21
-7
lines changed

4 files changed

+21
-7
lines changed
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
This operation copies the ``profiles`` collection from the ``users``
2-
database on the server at ``mongodb.example.net``. The operation only
2+
database on the server at ``mongodb.example.net`` into the ``users``
3+
database on the local server. The operation only
34
copies documents that satisfy the query ``{ 'active' : true }``.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
.. code-block:: javascript
22
3-
db.runCommand( { cloneCollection: "users.profiles",
3+
db.getSiblingDB("users").runCommand( { cloneCollection: "users.profiles",
44
from: "mongodb.example.net:27017",
5-
query: { 'active' : true }
5+
query: { 'active' : true }
66
} )
77
88
.. include:: /includes/example-clone-collection-text.rst

source/includes/extracts-cloneCollection.yaml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,21 @@ replacement:
1919
cloneCollection: :dbcommand:`cloneCollection`
2020
---
2121
ref: cloneCollection-behavior-method
22-
inherit:
23-
file: extracts-cloneCollection.yaml
24-
ref: _cloneCollection-behavior
22+
content: |
23+
:program:`mongos` does not support {{cloneCollection}}.
24+
25+
When copying the specified collection, {{cloneCollection}} uses the same
26+
database name in the ``from`` server as the destination database. If the
27+
collection does not exist, {{cloneCollection}} fails.
28+
29+
{{cloneCollection}} cannot be used if the ``from`` server has
30+
:doc:`authorization </core/authorization>` enabled.
31+
32+
.. versionchanged:: 3.0
33+
34+
If the given :term:`collection` already exists in the destination
35+
:program:`mongod` instance, {{cloneCollection}} returns an
36+
error.
2537
replacement:
2638
cloneCollection: :method:`db.cloneCollection()`
2739
...

source/reference/method/db.cloneCollection.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ Example
3232

3333
.. code-block:: javascript
3434

35-
db.cloneCollection('mongodb.example.net:27017', 'users.profile',
35+
use users
36+
db.cloneCollection('mongodb.example.net:27017', 'profiles',
3637
{ 'active' : true } )
3738

3839
.. include:: /includes/example-clone-collection-text.rst

0 commit comments

Comments
 (0)