Hi Guest

HomePage

1 1

To improves our performance please Like Share Subscribe(Will boost us)

How to create a collection in MongoDB and example with parameter?
Question Posted on 18 Jul 2021

Home >> BigData >> MongoDB >> How to create a collection in MongoDB and example with parameter?

How to create a collection in MongoDB and example with parameter?
In MongoDB we use db.createCollection(name, options) to create collection. And below is the syntax to create collection in MongoDB with some parameter list.

db.createCollection(name, options)

In above command we have two parameter name and options. Here Name is name of collection which we create. And now second parameter Options which is document which is used to specify configuration of collection.


In second parameter options we have list of below given options
0
0

FieldTypeDescription
CappedBooleanHere true means enables a capped collection. And definition of Capped collection is a fixed size collection which will automatically overwrites oldest entries when it will reaches the maximum size. IF we specify the true then we need to specify the size of parameter also.
autoIndexIdBooleanDefault value is false and if we use true the it will automatically create index on _id field.
sizenumberHere specifies the maximum size in bytes for capped collection. When we choose capped as true then we need to specify this field also.
maxnumberHere we specifies the maximum number of documents allowed in capped collection.
Final Syntax db.createCollection("myTestcol", { capped : true, autoIndexID : true, size : 6142800, max : 10000 } )


Most Visited Questions:-

Deep Learning Questions Answers
Below are the different Deep Leaning Questions and answer a More...

Continuous Integration Questions Answers
Below are the 20 odd questions for CI or Continuous Integra More...

Derived relationships in Association Rule Mining are represented in the form of __________.
Derived relationships in Association Rule Mining are repres More...

What is Gulpjs and some multiple choice questions on Gulp
Gulpjs is an open source whihc helps in building Javascript More...

Microservices Architecture Questions Answers
Below are the different questions on Microservices Architec More...




Other Important Questions
Is MongoDB is RDBMS or not
What are the four Vs of Big Data?
What type of Database is MongoDB
Why 32-bit System not suitable for MongoDB
What feature of MongoDB is used for safe backups






Most Visited Questions
Top Searches:asp net questions vb net questions sql query uddl questions class javascript Questions sharepoint interview questions and concept silverlight questions and concept wcf questions beans general knowledge ajax questions
PHP | Biztalk | Testing | SAP | HR |
     
 
Privacy policy | Terms and Conditions | Blog


If the copyright of any questions or content or syntax belong to you email us we will remove that(info@crackyourinterview.com or crackyourinterview2018@gmail.com)
 

1
Home About Us GroupChat
 
Sitemap Feedback Contact us