From 4c678cb0c1c7b3f82f3279fbb7d2bd96370734a6 Mon Sep 17 00:00:00 2001 From: Andrew Aldridge Date: Tue, 7 Oct 2014 11:20:29 -0400 Subject: [PATCH] DOCS-4061: Capped collection documentation --- source/core/capped-collections.txt | 4 ++ source/reference/command/collStats.txt | 51 ++++++++++++-------------- 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/source/core/capped-collections.txt b/source/core/capped-collections.txt index cb5a9425e1a..aae0e7e6e4c 100644 --- a/source/core/capped-collections.txt +++ b/source/core/capped-collections.txt @@ -126,6 +126,10 @@ internal overhead. db.createCollection( "log", { capped: true, size: 100000 } ) +If the ``size`` field is less than or equal to 4096, then the collection will +have a cap of 4096 bytes. Otherwise, MongoDB will raise the provided size to +make it an integer multiple of 256. + Additionally, you may also specify a maximum number of documents for the collection using the ``max`` field as in the following document: diff --git a/source/reference/command/collStats.txt b/source/reference/command/collStats.txt index 329d9b28aa0..29e2531869e 100644 --- a/source/reference/command/collStats.txt +++ b/source/reference/command/collStats.txt @@ -50,6 +50,19 @@ Definition The scale factor rounds values to whole numbers. This can produce unpredictable and unexpected results in some situations. + If :dbcommand:`collStats` operates on a :term:`capped collection`, then the + following fields will also be present: + + .. code-block:: javascript + + > db.users.stats() + { + ... + "capped" : true, + "max" : NumberLong("9223372036854775807"), + "ok" : 1 + } + Output ------ @@ -142,7 +155,7 @@ Output Reports the flags on this collection set by the user. In version 2.2 the only user flag is :collflag:`usePowerOf2Sizes`. If :collflag:`usePowerOf2Sizes` is enabled, :data:`~collStats.userFlags` will - be set to ``1``, otherwise :data:`~collStats.userFlags` will be ``0``. + be set to ``1``, otherwise it will be ``0``. See the :dbcommand:`collMod` command for more information on setting user flags and :collflag:`usePowerOf2Sizes`. @@ -157,30 +170,12 @@ Output This field specifies the key and size of every existing index on the collection. The ``scale`` argument affects this value. -Example -------- - -The following is an example of :method:`db.collection.stats()` and -:dbcommand:`collStats` output: - -.. code-block:: javascript - - { - "ns" : ".", - "count" : , - "size" : , - "avgObjSize" : , - "storageSize" : , - "numExtents" : , - "nindexes" : , - "lastExtentSize" : , - "paddingFactor" : , - "systemFlags" : , - "userFlags" : , - "totalIndexSize" : , - "indexSizes" : { - "_id_" : , - "a_1" : - }, - "ok" : 1 - } +.. data:: collStats.capped + + This field will be "true" if the collection is + :term:`capped `. + +.. data:: collStats.max + + Shows the maximum number of documents that may be present in a + :term:`capped collection`.