crackyourinterview.com


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 2021Home >> 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






@2014-2022 Crackyourinterview (All rights reserved)
Privacy Policy - Disclaimer - Sitemap