Skip to content

DOCS-1492 sh._lastMigration, db.createCollection #1152

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
61 changes: 61 additions & 0 deletions source/reference/method/db.createCollection-options-param.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
object:
name: db.createCollection
type: method
field:
optional: true
type: field
name: capped
type: Boolean
position: 1
description: |
Enables a :term:`capped collection`. To create a capped collection,
specify ``true``. If you specify ``true``, you must also set a maximum
size in the ``size`` field.
---
object:
name: db.createCollection
type: method
field:
optional: true
type: field
name: autoIndexID
type: Boolean
position: 2
description: |
If ``capped`` is ``true``, specify ``false`` to disable the automatic
creation of an index on the ``_id`` field. Before 2.2, the default
value for ``autoIndexId`` was ``false``. See
:ref:`2.2-id-indexes-capped-collections` for more information.
---
object:
name: db.createCollection
type: method
field:
optional: true
type: field
name: size
type: number
position: 3
description: |
Specifies a maximum size in bytes for a capped collection. The
``size`` field is required for capped collections. If ``capped`` is
false, you can use this field to preallocate space for an ordinary
collection.
---
object:
name: db.createCollection
type: method
field:
optional: true
type: field
name: max
type: number
position: 4
description: |
The maximum number of documents allowed in the capped collection. The
``size`` limit takes precedence over this limit. If a capped
collection reaches its maximum ``size`` before it reaches the maximum
number of documents, MongoDB removes old documents. If you prefer to
use this limit, ensure that the ``size`` limit, which is required, is
sufficient to contain the documents limit.
...
25 changes: 25 additions & 0 deletions source/reference/method/db.createCollection-param.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
object:
name: db.createCollection
type: method
field:
optional: false
type: param
name: name
type: string
position: 1
description: |
The name of the collection to create.
---
object:
name: db.createCollection
type: method
field:
optional: true
type: param
name: options
type: document
position: 2
description: |
Configuration options for creating a capped collection or for
preallocating space in a new collection.
...
99 changes: 47 additions & 52 deletions source/reference/method/db.createCollection.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,63 +4,58 @@ db.createCollection()

.. default-domain:: mongodb

.. method:: db.createCollection(name, [{capped: <boolean>, size: <value>, max <bytes>}] )

:param string name: Specifies the name of a collection to create.

:param document capped: Optional. If this :term:`document` is
present, this command creates a capped
collection. The capped argument is a
:term:`document` that contains the
following three fields:

:param boolean capped: Enables a :term:`collection cap <capped
collection>`. False by default. If enabled,
you must specify a ``size`` parameter.

:param bytes size: If ``capped`` is ``true``, ``size`` specifies a
maximum size in bytes for the capped collection.
When ``capped`` is false, you may use ``size`` to
preallocate space.

:option autoIndexId: If ``capped`` is ``true`` you can specify
``false`` to disable the automatic index
created on the ``_id`` field. Before 2.2, the
default value for ``autoIndexId`` was
``false``. See :ref:`2.2-id-indexes-capped-collections`
for more information.

:param int max: Optional. Specifies a maximum "cap," in number of
documents for capped collections. You must also
specify ``size`` when specifying ``max``.

Explicitly creates a new collection. Because MongoDB creates
collections implicitly when referenced, this command is primarily
used for creating new capped collections. In some circumstances,
you may use this command to pre-allocate space for an ordinary
collection.

Capped collections have maximum size or document counts that
prevent them from growing beyond maximum thresholds. All capped
collections must specify a maximum size, but may also specify a
maximum document count. MongoDB will remove older documents
if a collection reaches the maximum size limit before it reaches
the maximum document count. Consider the following example:
Definition
----------

.. code-block:: javascript
.. method:: db.createCollection(name, options)

db.createCollection("log", { capped : true, size : 5242880, max : 5000 } )
Creates a new collection explicitly.

This command creates a collection named ``log`` with a maximum size of
5 megabytes and a maximum of 5000 documents.
Because MongoDB creates a collection implicitly when the collection
is first referenced in a command, this method is used primarily for
creating new :term:`capped collections <capped collection>`. This is
also used to pre-allocate space for an ordinary collection.

The following command simply pre-allocates a 2 gigabyte, uncapped
collection named ``people``:
The :method:`~db.createCollection` has the following prototype form:

.. code-block:: javascript

db.createCollection("people", { size: 2147483648 })
db.createCollection(name, {capped: <Boolean>, autoIndexID: <Boolean>, size: <number>, max <number>} )

The :method:`~db.createCollection` method has the following parameters:

.. include:: /reference/method/db.createCollection-param.rst

The ``options`` document creates a capped collection or preallocates
space in a new ordinary collection. The ``options`` document contains
the following fields:

.. include:: /reference/method/db.createCollection-options-param.rst

Example
-------

The following example creates a capped collection. Capped collections
have maximum size or document counts that prevent them from growing
beyond maximum thresholds. All capped collections must specify a maximum
size and may also specify a maximum document count. MongoDB removes
older documents if a collection reaches the maximum size limit before it
reaches the maximum document count. Consider the following example:

.. code-block:: javascript

db.createCollection("log", { capped : true, size : 5242880, max : 5000 } )

This command creates a collection named ``log`` with a maximum size of 5
megabytes and a maximum of 5000 documents.

The following command simply pre-allocates a 2-gigabyte, uncapped
collection named ``people``:

.. code-block:: javascript

db.createCollection("people", { size: 2147483648 } )

This command provides a wrapper around the database command
:dbcommand:`create`. See :doc:`/core/capped-collections` for more
information about capped collections.
This command provides a wrapper around the database command
:dbcommand:`create`. See :doc:`/core/capped-collections` for more
information about capped collections.
13 changes: 13 additions & 0 deletions source/reference/method/sh._lastMigration-param.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
object:
name: sh._lastMigration
type: method
field:
optional: false
type: param
name: namespace
type: string
position: 1
description: |
The :term:`namespace` of a database or collection within the current
database.
...
57 changes: 38 additions & 19 deletions source/reference/method/sh._lastMigration.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,52 @@ sh._lastMigration()

.. default-domain:: mongodb

Definition
----------

.. method:: sh._lastMigration(namespace)

:param string namespace: The name of a database or collection within the
current database.
Returns information on the last migration performed on the specified
database or collection.

The :method:`sh._lastMigration()` method has the following parameter:

.. include:: /reference/method/sh._lastMigration-param.rst

Output
------

The :method:`sh._lastMigration()` method returns a document with details
about the last migration performed on the database or collection. The
document contains the following output:

.. data:: sh._lastMigration._id

The id of the migration task.

.. data:: sh._lastMigration.server

The name of the server.

.. data:: sh._lastMigration.clientAddr

:returns: A document with fields detailing the most recent migration
in the specified namespace.
The IP address and port number of the server.

:method:`sh._lastMigration()` returns a document with details about
the last migration performed on the database or collection you specify.
.. data:: sh._lastMigration.time

Document details:

:field string _id: The id of the migration task
The time of the last migration, formatted as :term:`ISODate`.

:field string server: The name of the server
.. data:: sh._lastMigration.what

:field string clientAddr: The IP address and port number of the server.
The specific type of migration.

:field ISODate time: The time of the last migration.
.. data:: sh._lastMigration.ns

:field string what: The specific type of migration.
The complete :term:`namespace` of the collection affected by the
migration.

:field string ns: The complete namespace of the collection affected
by the migration.
.. data:: sh._lastMigration.details

:field document details: A document containing details about the
migrated chunk. Includes ``min`` and ``max``
sub-documents with the bounds of the migrated
chunk.
A document containing details about the migrated chunk. The document
includes ``min`` and ``max`` sub-documents with the bounds of the
migrated chunk.