How To Display Collections In Mongodb
Use mydb show collections output.
How to display collections in mongodb. To query data from mongodb collection you need to use mongodb s find method. True that allows a user without the required privilege i e. Learn the top 10 most common commands for mongodb beginners including the command to log into mongodb show all databases and select a database to work with. In this chapter we will learn how to query document from mongodb collection.
Listcollections action on the database to run the command when access control is enforced. Mongodb show collection use show collections command from mongodb shell to list all collections created in the current database. This is possible because mongodb is a schema free database. A flag when set to true and used with nameonly.
A collection is analogous to a table of an rdbms. It is similar to tables in mysql to store the records. A collection may store a number of documents. To view the collection you need to select the one that you want to view.
A collection may store documents those who are not same in structure. Find method displays the documents in a non structured format but to display the results in a formatted way the pretty method can be used. When both authorizedcollections and nameonly options are set to true the command returns only those collections for which the user has privileges. Mongodb list collection is all about storage for the document.
Mongodb is a schema less database so it can store any number of fields to the documents. In a relational database like mysql a schema defines the organization structure of data in a database. What is mongodb list collections. First select the database you want to view the collection.
Tecadmin accounts mycol pproducts users. Mongodb show collection is a command from the mongodb shell that helps in listing the collections created in the current database. Mongodb show collection select your database and run show collections command to list available collections in mongodb database. If we want to fetch all documents from the collection the following mongodb command can be used.