MongoDB Interview Questions and Answers
Question - 41 : - What are the components of the Sharded cluster?
Answer - 41 : - The sharded cluster has the following components:
1. Shards
2. Query routers
3. Config servers
Question - 42 : - Which command is used to create a database?
Answer - 42 : - To create a database, we can use the Database_Name command.
Question - 43 : - Which command is used to drop a database?
Answer - 43 : - The db.dropDatabse() command is used to drop a database
Question - 44 : - What is the use of the pretty() method?
Answer - 44 : - The pretty() method is used to show the results in a formatted way.
Question - 45 : - Which method is used to remove a document from a collection?
Answer - 45 : - The remove() method is used to remove a document from a collection.
Question - 46 : - Define MongoDB Projection.
Answer - 46 : - Projection is used to select only the necessary data. It does not select the whole data of a document
Question - 47 : - What is the use of the limit() method?
Answer - 47 : - The limit() method is used to limit the records in the database.
Question - 48 : - What is the syntax of the limit() method?
Answer - 48 : - The syntax of the limit() method is as follows:
>db.COLLECTION_NAME.find().limit(NUMBER)
Question - 49 : - What is the syntax of the sort() method?
Answer - 49 : - In MongoDB, the following syntax is used for sorting documents:
>db.COLLECTION_NAME.find().sort({KEY:1})
Question - 50 : - Which command is used to create a backup of the database?
Answer - 50 : - The mongodump command is used to create a backup of the database.