mongodbHow to create a collection in MongoDB?
Creating a collection in MongoDB is a simple process. To create a collection, use the db.createCollection() method. The syntax for this method is as follows:
db.createCollection(name, options)
name: The name of the collection to be created.options: This is an optional parameter. It is a document that specifies the configuration of the collection.
Example
db.createCollection("customers", { capped : true, autoIndexId : true, size : 6142800, max : 10000 } )
Output example
{ "ok" : 1 }
Helpful links
More of Mongodb
- How to use watch in MongoDB?
- How to use unwind in MongoDB?
- How to use triggers in MongoDB?
- What is MongoDB default port?
- How to check if array is empty in MongoDB?
- How to implement one-to-many relation in MongoDB?
- How to use the limit operator in MongoDB?
- How to kill an operation in MongoDB?
- How to get all documents in MongoDB?
- How to do text search in MongoDB?
See more codes...