Skip to content

DOCS-1492 param tables: addShard captrunc cloneCollection compact #1025

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions source/reference/command/addShard-field.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
object:
name: addShard
type: dbcommand
field:
optional: false
type: field
name: addShard
type: string
position: 1
description: |
The hostname and port of the :program:`mongod` instance to be added
as a shard. To add a replica set as a shard, specify the name
of the replica set and the hostname and port of a member of the replica set.
---
object:
name: addShard
type: dbcommand
field:
optional: true
type: field
name: maxSize
type: integer
position: 2
description: |
The maximum size in megabytes of the shard. If you set ``maxSize``
to ``0``, MongoDB does not limit the size of the shard.
---
object:
name: addShard
type: dbcommand
field:
optional: true
type: field
name: name
type: string
position: 3
description: |
A name for the shard. If this is not specified, MongoDB
automatically provides a unique name.
...
22 changes: 11 additions & 11 deletions source/reference/command/addShard.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,29 @@ Definition

.. dbcommand:: addShard

The :dbcommand:`addShard` command adds a database instance or
:term:`replica set` to a :term:`sharded cluster`. The optimal
configuration is to deploy shards across replica sets.
Adds either a database instance or a :term:`replica set` to a
:term:`sharded cluster`. The optimal configuration is to deploy
shards across replica sets.

You run this command when connected a :program:`mongos` instance. The
command takes the following form when adding a database instance:
Run this command when connected a :program:`mongos` instance. The
command takes the following form when adding a single database
instance as a shard:

.. code-block:: javascript

{ addShard: "<hostname><:port>", maxSize:<size>, name: "<shard_name>" }
{ addShard: "<hostname><:port>", maxSize: <size>, name: "<shard_name>" }

The command takes the following form when adding a replica set as a
shard:
When adding a replica set as a shard, use the following form:

.. code-block:: javascript

{ addShard: "<replica_set>/<hostname>:<port>", maxSize:<size>, name: "<shard_name>" }
{ addShard: "<replica_set>/<hostname><:port>", maxSize: <size>, name: "<shard_name>" }

The command contains the following fields:

.. include:: /reference/command/addShard-param.rst
.. include:: /reference/command/addShard-field.rst

The :dbcommand:`addShard` command adds stores shard configuration
The :dbcommand:`addShard` command stores shard configuration
information in the :term:`config database`.

Specify a ``maxSize`` when you have machines with different disk
Expand Down
33 changes: 33 additions & 0 deletions source/reference/command/captrunc-field.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
object:
name: captrunc
type: dbcommand
field:
optional: false
type: field
name: captrunc
type: string
position: 1
description: "The name of the collection to truncate."
---
object:
name: captrunc
type: dbcommand
field:
optional: false
type: field
name: n
type: integer
position: 2
description: "The number of documents to remove from the collection."
---
object:
name: captrunc
type: dbcommand
field:
optional: false
type: field
name: inc
type: boolean
position: 3
description: "Specifies whether to truncate the nth document."
...
41 changes: 24 additions & 17 deletions source/reference/command/captrunc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,41 @@ captrunc

.. default-domain:: mongodb

Definition
----------

.. dbcommand:: captrunc

The :dbcommand:`captrunc` command is an internal command that
truncates capped collections.
Truncates capped collections.

:param string collection: The name of the collection to truncate.
.. |dbcommand| replace:: :dbcommand:`captrunc`
.. include:: /includes/note-enabletestcommands.rst

:param integer n: An integer that specifies the number of documents
to remove from the collection
The command takes the following form:

:param boolean inc: Specifies whether to truncate the ``n``\ th document.
.. code-block:: javascript

.. example::
{ captrunc: "<collection>", n: <integer>, inc: <true|false> }.

Truncate 10 older documents from the collection ``records``:
The command contains the following fields:

.. code-block:: javascript
.. include:: /reference/command/captrunc-field.rst

db.runCommand({captrunc: "records" , n:10})
Examples
--------

Truncate 100 documents and the 101st document:
The following command truncates 10 older documents from the collection
``records``:

.. code-block:: javascript
.. code-block:: javascript

db.runCommand({captrunc: "records", n:100, inc:true})
db.runCommand({captrunc: "records" , n:10})

.. |dbcommand| replace:: :dbcommand:`captrunc`
.. include:: /includes/note-enabletestcommands.rst
The following command truncates 100 documents and the 101st document:

.. code-block:: javascript

db.runCommand({captrunc: "records", n:100, inc:true})

.. write-lock
.. testcommand
.. write-lock
.. testcommand
51 changes: 51 additions & 0 deletions source/reference/command/cloneCollection-field.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
object:
name: cloneCollection
type: dbcommand
field:
optional: false
type: field
name: cloneCollection
type: string
position: 1
description: "The name of the collection to clone."
---
object:
name: cloneCollection
type: dbcommand
field:
optional: false
type: field
name: from
type: string
position: 2
description: |
Specify a resolvable hostname and optional port number of the remote
server where the specified collection resides."
---
object:
name: cloneCollection
type: dbcommand
field:
optional: true
type: field
name: query
type: document
position: 3
description: |
A query that filters the documents in the remote collection that
:dbcommand:`cloneCollection` will copy to the current database.
---
object:
name: cloneCollection
type: dbcommand
field:
optional: true
type: field
name: copyIndexes
type: boolean
position: 4
description: |
If set to ``false`` the indexes on the originating server are not
copied with the documents in the collection. This is set to ``true``
by default.
...
62 changes: 28 additions & 34 deletions source/reference/command/cloneCollection.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,42 @@ cloneCollection

.. default-domain:: mongodb

Definition
----------

.. dbcommand:: cloneCollection

The :dbcommand:`cloneCollection` command copies a collection from a
remote server to the server where you run the
command. :dbcommand:`cloneCollection` does not allow you to clone a
collection through a :program:`mongos`: you must connect directly
to the :program:`mongod` instance.
Copies a collection from a remote server to the server where you run
the command. You cannot clone a collection through a
:program:`mongos` but must connect directly to the :program:`mongod`
instance.

The command takes the following form:

:param from:
.. code-block:: javascript

Specify a resolvable hostname, and optional port number
of the remote server where the specified collection resides.
{ cloneCollection: "<collection>", from: "<hostname>", query: { <query> }, copyIndexes: <true|false> }

:param query:
The command uses the following fields:

Optional. A query document, in the form of a :term:`document`,
that filters the documents in the remote collection that
:dbcommand:`cloneCollection` will copy to the current
database. See :method:`db.collection.find()`.
.. include:: /reference/command/cloneCollection-field.rst

:param Boolean copyIndexes:
Example
-------

Optional. ``true`` by default. When set to ``false`` the indexes
on the originating server are *not* copied with the documents in
the collection.
.. code-block:: javascript

Consider the following example:
{ cloneCollection: "users.profiles", from: "mongodb.example.net:27017", query: { active: true }, copyIndexes: false }

.. code-block:: javascript
This operation copies the ``profiles`` collection from the ``users``
database on the server at ``mongodb.example.net``. The operation only
copies documents that satisfy the query ``{ active: true }`` and does
not copy indexes. :dbcommand:`cloneCollection` copies indexes by
default, but you can disable this behavior by setting ``{ copyIndexes:
false }``. The ``query`` and ``copyIndexes`` arguments are optional.

{ cloneCollection: "users.profiles", from: "mongodb.example.net:27017", query: { active: true }, copyIndexes: false }

This operation copies the ``profiles`` collection from the
``users`` database on the server at ``mongodb.example.net``. The operation only
copies documents that satisfy the query ``{ active: true }`` and
does not copy indexes. :dbcommand:`cloneCollection` copies indexes
by default, but you can disable this behavior by setting ``{
copyIndexes: false }``. The ``query`` and ``copyIndexes``
arguments are optional.

:dbcommand:`cloneCollection` creates a collection on the current
database with the same name as the origin collection. If, in the
above example, the ``profiles`` collection already exists in the local
database, then MongoDB appends documents in the remote collection
to the destination collection.
:dbcommand:`cloneCollection` creates a collection on the current
database with the same name as the origin collection. If, in the above
example, the ``profiles`` collection already exists in the local
database, then MongoDB appends documents in the remote collection to the
destination collection.
62 changes: 62 additions & 0 deletions source/reference/command/compact-field.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
object:
name: compact
type: dbcommand
field:
optional: false
type: field
name: compact
type: string
position: 1
description: "The name of the collection."
---
object:
name: compact
type: dbcommand
field:
optional: true
type: field
name: force
type: boolean
position: 2
description: |
If ``true``, :dbcommand:`compact` can run on the
:term:`primary` in a :term:`replica set`. If ``false``,
:dbcommand:`compact` returns an error when run on a
primary, because the command blocks all other activity.
Beginning with version 2.2, :dbcommand:`compact` blocks
activity only for the database it is compacting.
---
object:
name: compact
type: dbcommand
field:
optional: true
type: field
name: paddingFactor
type: number
position: 3
description: |
Describes the :term:`record size` allocated for each
document as a factor of the document size for all records
compacted during the :dbcommand:`compact` operation. The
``paddingFactor`` does not affect the padding of subsequent
record allocations after :dbcommand:`compact` completes.
For more information, see :ref:`compact-paddingFactor`.
---
object:
name: compact
type: dbcommand
field:
optional: true
type: field
name: paddingBytes
type: integer
position: 4
description: |
Sets the padding as an absolute number of bytes for all
records compacted during the :dbcommand:`compact`
operation. After :dbcommand:`compact` completes,
``paddingBytes`` does not affect the padding of subsequent
record allocations. For more information, see
:ref:`compact-paddingBytes`.
...
Loading