- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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
How to list all collections in the Mongo shell?
To list all collections in Mongo shell, you can use the function getCollectionNames().
The syntax is as follows −
db.getCollectionNames();
You can use another command which is collections. The syntax is as follows −
show collections;
To list all collections in Mongo, use the above two functions. The query is as follows −
> db.getCollectionNames();
The following is the output −
[ "ConvertStringToDateDemo", "IdUpdateDemo", "ProductsInformation", "addFieldDemo", "addNewFieldToEveryDocument", "arrayInnerElementsDemo", "arrayLengthGreaterThanOne", "arrayOfArraysDemo", "caseInsensitiveDemo", "changeDataType", "changeType", "charactersAllowedDemo", "charactersDemo", "checkFieldContainsStringDemo", "checkSequenceDemo", "combinationOfArrayDemo", "conditionalSumDemo", "convertStringToNumberDemo", "copyThisCollectionToSampleDatabaseDemo", "countDemo", "createSequenceDemo", "distinctCountValuesDemo", "distinctRecordDemo", "distinctWithMultipleKeysDemo", "employeeInformation", "filterArray", "findAllDuplicateKeyDocumentDemo", "findByMultipleArrayDemo", "findDuplicateByKeyDemo", "findDuplicateRecordsDemo", "findSpecificValue", "findValueInArrayWithMultipleCriteriaDemo", "getLastNRecordsDemo", "getParticularElementFromArrayDemo", "getPartuclarElement", "getSizeOfArray", "groupByDateDemo", "incrementValueInNestedArrayDemo", "insertIfNotExistsDemo", "nestedArrayDemo", "notLikeOpeartorDemo", "regExpOnIntegerDemo", "removeArrayDemo", "removeArrayElement", "removeArrayElements", "removeDuplicateDocumentDemo", "removeElementFromDoublyNestedArrayDemo", "removeFieldCompletlyDemo", "removeObject", "renameFieldDemo", "reverseRegexDemo", "searchArrayDemo", "selectSingleFieldDemo", "singleFieldDemo", "sortDemo", "sortInnerArrayDemo", "sourceCollection", "stringFieldLengthDemo", "test.js", "uniqueIndexOnArrayDemo", "unwindOperatorDemo", "updateExactField", "updateIdDemo", "updateObjects" ]
Here is the second query to display all collections from Mongo. The query is as follows −
> show collections;
The following is the output −
ConvertStringToDateDemo IdUpdateDemo ProductsInformation addFieldDemo addNewFieldToEveryDocument arrayInnerElementsDemo arrayLengthGreaterThanOne arrayOfArraysDemo caseInsensitiveDemo changeDataType changeType charactersAllowedDemo charactersDemo checkFieldContainsStringDemo checkSequenceDemo combinationOfArrayDemo conditionalSumDemo convertStringToNumberDemo copyThisCollectionToSampleDatabaseDemo countDemo createSequenceDemo distinctCountValuesDemo distinctRecordDemo distinctWithMultipleKeysDemo employeeInformation filterArray findAllDuplicateKeyDocumentDemo findByMultipleArrayDemo findDuplicateByKeyDemo findDuplicateRecordsDemo findSpecificValue findValueInArrayWithMultipleCriteriaDemo getLastNRecordsDemo getParticularElementFromArrayDemo getPartuclarElement getSizeOfArray groupByDateDemo incrementValueInNestedArrayDemo insertIfNotExistsDemo nestedArrayDemo notLikeOpeartorDemo regExpOnIntegerDemo removeArrayDemo removeArrayElement removeArrayElements removeDuplicateDocumentDemo removeElementFromDoublyNestedArrayDemo removeFieldCompletlyDemo removeObject renameFieldDemo reverseRegexDemo searchArrayDemo selectSingleFieldDemo singleFieldDemo sortDemo sortInnerArrayDemo sourceCollection stringFieldLengthDemo test.js uniqueIndexOnArrayDemo unwindOperatorDemo updateExactField updateIdDemo updateObjects
- Related Articles
- How to list all databases in the Mongo shell?
- How to list all users in the Mongo shell?
- Inserting Date() in MongoDB through Mongo shell?
- How to list all the Collections in a MongoDB database using Java?
- How to list all collections from a particular MongoDB database?
- How to get all the collections from all the MongoDB databases?
- Does Mongo shell treats numbers as float by default.? How can we work it around explicitly?
- How to operate on all databases from the MongoDB shell?
- How to use Remove, RemoveAt, RemoveRange methods in C# list collections?
- Is there a way to list collections in MongoDB?
- How to get all collections where collection name like '%2015%'?
- How to merge array of documents in Mongo DB?
- How to Use lua-mongo library in Lua Programming?
- How to use remove(obj), remove(index), and removeAll() methods in Java list collections?
- Find all collections in MongoDB with specific field?

Advertisements