Skip to content

Commit 04cd039

Browse files
author
Sam Kleinman
committed
DOCS-946: changing cloneCollection documentation to reflect actual behavior
1 parent 71bc354 commit 04cd039

File tree

3 files changed

+38
-6
lines changed

3 files changed

+38
-6
lines changed

source/core/document.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,8 @@ Consider the following options for the value of an ``_id`` field:
245245
information concerning UUID interoperability.
246246

247247
.. _documents-query-selectors:
248+
.. _mongodb-query-documents:
249+
.. _mongodb-query-document:
248250

249251
Query Specification Documents
250252
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

source/reference/command/cloneCollection.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ cloneCollection
2727

2828
.. code-block:: javascript
2929

30-
{ cloneCollection: "users", from: "db.example.net:27017", query: { active: true }, copyIndexes: false }
30+
{ cloneCollection: "users.profiles", from: "mongodb.example.net:27017", query: { active: true }, copyIndexes: false }
3131

32-
This operation copies the "users" collection from the current
33-
database on the server at ``db.example.net``. The operation only
32+
This operation copies the ``profiles`` collection from the
33+
``users`` database on the server at ``mongodb.example.net``. The operation only
3434
copies documents that satisfy the query ``{ active: true }`` and
3535
does not copy indexes. :dbcommand:`cloneCollection` copies indexes
3636
by default, but you can disable this behavior by setting ``{
@@ -39,6 +39,6 @@ cloneCollection
3939

4040
:dbcommand:`cloneCollection` creates a collection on the current
4141
database with the same name as the origin collection. If, in the
42-
above example, the ``users`` collection already exists, then
43-
MongoDB appends documents in the remote collection to the
44-
destination collection.
42+
above example, the ``users`` collection already exists in the local
43+
database, then MongoDB appends documents in the remote collection
44+
to the destination collection.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
====================
2+
db.cloneCollection()
3+
====================
4+
5+
.. default-domain:: mongodb
6+
7+
.. method:: db.cloneCollection(from, collection, query)
8+
9+
:method:`db.cloneCollection()` provides a wrapper around
10+
:dbcommand:`cloneCollection` for copying data directly between
11+
:MongoDB instances.
12+
13+
:param string from: A host name, of the MongoDB instance that holds
14+
the collection you wish to copy
15+
16+
:param string collection: A collection in the MongoDB instance that
17+
you want to
18+
copy. :method:`db.cloneCollection()` will
19+
only copy the collection with this name
20+
from *database* of the same name as the
21+
current database the remote MongoDB
22+
instance. If you want to copy a
23+
collection from a different database name
24+
you must use the
25+
:dbcommand:`cloneCollection` directly.
26+
27+
:param document query: Optional. A standard :ref:`MongoDB query
28+
document <mongodb-query-document>` to limit
29+
the documents copied as part of the
30+
:method:`db.cloneCollection()` operation.

0 commit comments

Comments
 (0)