MongoDB Interview Question & Answer Series 1

1. Give details on iterating cursor in mongoDB?
Iterating cursor in mongoDB is accomplished using db.collection.find() command. This find() command gets a cursor of documents. By default first 20 documents in collection are returned by mongoDB. To fetch and process/print more documents, use hasNext() function
2. When does a cursor gets closed in mongoDB?
MongoDB server by default closes cursor after 10 minutes of inactivity. Cursor is closed when a client exhausts the cursor
3. How to avoid the cursor inactivity and timeout behaviour?
This default behaviour can be overridden using notimeout flag
3. What are the options available in mongo shell that tweak cursor behaviour?
Mongo shell provieds many options that tweak cursor behaviour. These are the cursor flags:
4. How can we increment the _id sequence number?
Adopt one of the following two procedures :
1) Make use of counters() collection
2) Make use of user coded looping
5. What is the maximum size of mongoDB document?
MongoDB can grow upto 16MB the maximum size of a BSON document. When creating a record mongoDB allocates some extra space that can be utilized in future. This is an proactive measure to allocate additional space to growing mongoDB document. This is called record padding
6) What is the default primary key field in mongoDB?
By default every collection comes with _id column
7) What is CRUD in mongoDB?
Basic database operations – create, Read, Update, Delete

MongoDB,NoSQL Database Articles,Tutorials, Free Interview Q&A,Training

Delivered by FeedBurner