Explicitly creates a collection. create has the following form:

{ create: <collection_name>,
  capped: <true|false>,
  autoIndexId: <true|false>,
  size: <max_size>,
  max: <max_documents>

create has the following fields:

Field Type Description
create string The name of the new collection.
capped Boolean Optional. To create a capped collection. specify true. If you specify true, you must also set a maximum size in the size field.
autoIndexId Boolean Optional. Specify false to disable the automatic creation of an index on the _id field. Before 2.2, the default value for autoIndexId was false.
size integer Optional. The maximum size for the capped collection. Once a capped collection reaches its maximum size, MongoDB overwrites older old documents with new documents. The size field is required for capped collections.
max integer Optional. The maximum number of documents to keep 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 use this limit, ensure that the size limit is sufficient to contain the documents limit.

For more information on the autoIndexId field in versions before 2.2, see _id Fields and Indexes on Capped Collections.

The db.createCollection() method wraps the create command.


The create command obtains a write lock on the affected database and will block other operations until it has completed. The write lock for this operation is typically short lived. However, allocations for large capped collections may take longer.


To create a capped collection limited to 64 kilobytes, issue the command in the following form:

db.runCommand( { create: "collection", capped: true, size: 64 * 1024 } )
←   drop clone  →