| |
read source history
= createCollection() =
----
[[MongoDB Driver Function Reference]]
Creates a collection.
More information can be found in the corresponding entry of the [[https://docs.mongodb.com/manual/reference/method/db.createCollection/index.html|MongoDB Manual]].
[[[@cG
db.createCollection(<name>[, <options>])
]]]
**Arguments**
[[[@w
|@t0@r0@c0 <name> | | Collection name. |
| <options> | | A BOSN document specifying options. |
]]]
**Options**
[[[@cw
{ capped: collation: <document>, <boolean>, size: <number>, max: <number>, storageEngine: <document>,
validationLevel: <string>, validationAction: <string>, indexOptionDefaults: <document> }
<<@f:text>>
|@t0@r0@c0 collation| | A document specifying the [[https://docs.mongodb.com/manual/reference/bson-type-comparison-order/#collation|collation]]. |
| capped| | Creates a [[https://docs.mongodb.com/manual/reference/glossary/#term-capped-collection|capped collection]]. Must also specify //size// (default: false). |
| size | | Specifies the size of a [[https://docs.mongodb.com/manual/reference/glossary/#term-capped-collection|capped collection]]. |
| max| | Specifies the maximum number of documents in a [[https://docs.mongodb.com/manual/reference/glossary/#term-capped-collection|capped collection]]. |
| storageEngine | | Specifies a storage engine. |
| indexOptionDefaults | | Specifies the default index options. |
<<@/f>>
]]]
**Example**
[[[@cw
db.createCollection("employees");
]]]
Creates a collection named employees.
----
[[Main|home]] | [[MongoDB Driver Function Reference]] | [[MongoDB Driver]]
|