Crud Concepts And Operation(Engineering > Computer Science And Engineering > Mongodb ) Questions and Answers
Question 1. MongoDB stores all documents in :
tables
collections
rows
All of the mentioned
Explanation:-
Answer: Option B. -> collections
Collections are analogous to a table in relational databases.
Question 2. Which of the following method returns true if the cursor has documents ?
hasMethod()
hasNext()
hasDoc()
All of the mentioned
Explanation:-
Answer: Option B. -> hasNext()
hasNext() returns true if the cursor returned by the db.collection.find() query can iterate further to return more documents.
Question 3. In MongoDB, _________ operations modify the data of a single collection.
CRUD
GRID
READ
All of the mentioned
Explanation:-
Answer: Option A. -> CRUD
Data modification refers to operations that create, update, or delete data.
Question 4. After starting the mongo shell, your session will use the ________ database by default.
mongo
master
test
primary
Explanation:-
Answer: Option C. -> test
At any time,db operation at the mongo shell is used to report the name of the current database.
Question 5. Which of the following method is called while accessing documents using the array index notation ?
cur.toArray()
cursor.toArray()
doc.toArray()
All of the mentioned
Explanation:-
Answer: Option B. -> cursor.toArray()
The toArray() method returns an array that contains all the documents from a cursor.
Question 6. Which of the following method returns one document ?
findOne()
findOne1()
selectOne()
All of the mentioned
Explanation:-
Answer: Option A. -> findOne()
MongoDB provides a db.collection.findOne() method as a special case of find() that returns a single document.
Question 7. Which of the following is second argument to projection ?
findOne()
findOne1()
selectOne()
find()
Explanation:-
Answer: Option D. -> find()
Projections are the second argument to the find() method,which specify a list of fields to return or list fields to exclude in the result documents.
Question 8. Which of the following will display complete list of available cursor flags ?
cursor.Option()
cursor.addOption()
cursor.addOptions()
All of the mentioned
Explanation:-
Answer: Option B. -> cursor.addOption()
You should either close the cursor manually or exhaust the cursor.
Question 9. The ________ message is used to update a document in a collection.
UPDATE
OP_UPDATE
OP_UPDATES
All of the mentioned
Explanation:-
Answer: Option B. -> OP_UPDATE
Only the OP_QUERY and OP_GET_MORE messages result in a response from the database.
Question 10. The mongo shell and the MongoDB drivers use __________ as the default write concern.
Nacknowledged
Acknowledgement
Acknowledged
All of the mentioned
Explanation:-
Answer: Option C. -> Acknowledged
MongoDB allows clients to read documents inserted or modified before it commits these modifications to disk, regardless of write concern level or journaling configuration.