Hi Guest

MobileUser

1 HomePage 1 Jobs 1 WalkIn 1Articles  

Cat Exam

 :) Latest Topic
UDDI
HDP
CDH
Data Lakes
Commercial Vehicels
CouchDB
Bike Dealer
ASP.NET
VB.NET
SQL Query
 New Cars
 :) Hot Jobs
 
 :) Latest Articles


  

 


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 } )


 
 Input Your Comments Or suggestions(If Any)
 Name
 Email(optional)
 Comments


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






 
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 |