- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What does createdCollectionAutomatically mean in MongoDB?
If a collection does not exist then MongoDB creates a collection in indexing part. The createdCollectionAutomatically tells that the operation created a collection.
For our example, let us create a collection with an index −
> db.createCollectionDemo.createIndex({"ClientCountryName":1});
This will produce the following output −
{ "createdCollectionAutomatically" : true, "numIndexesBefore" : 1, "numIndexesAfter" : 2, "ok" : 1 }
Let us create a collection with documents −
> db.createCollectionDemo.insertOne({"ClientName":"Larry","ClientCountryName":"US"}); { "acknowledged" : true, "insertedId" : ObjectId("5cd2950be3526dbddbbfb612") }
Following is the query to display all documents from a collection with the help of find() method −
> db.createCollectionDemo.find().pretty();
This will produce the following output −
{ "_id" : ObjectId("5cd2950be3526dbddbbfb612"), "ClientName" : "Larry", "ClientCountryName" : "US" }
Advertisements