VOOZH about

URL: https://www.geeksforgeeks.org/quizzes/mongodb-crud-operations-quiz-questions/

⇱ Quiz about MongoDB CRUD Operations Quiz Questions


Last Updated :
Discuss
Comments

Question 1

How do you create a database in MongoDB?

  • db.createDatabase("<dbname>")

  • new Database("<dbname>")

  • use <dbname>

  • db.new("<dbname>")

Question 2

What happens when you execute db.dropDatabase()?

  • Deletes the current database and all its collections

  • Deletes only empty collections from the database

  • Removes only the database name but keeps the data

  • Raises an error if the database is not empty

Question 3

Which method is used to delete an entire collection in MongoDB?

  • db.collection.removeAll()

  • db.collection.drop()

  • db.collection.deleteMany({})

  • db.removeCollection("<collection_name>")

Question 4

Which method allows inserting multiple documents into a MongoDB collection at once?

  • insertOne()

  •  insertMany()

  • bulkInsert()

  • addDocuments()

Question 5

What does the updateOne() method do?

  • Updates all documents that match the filter

  • Updates the first matching document only

  • Replaces an entire document

  • Deletes a document before updating

Question 6

How do you delete all documents that match a given filter in MongoDB?

  • deleteAll()

  • removeMany()

  • deleteMany()

  • dropDocuments()

Question 7

How do you find a document with a specific _id in MongoDB?

  • db.collection.findById(id)

  • db.collection.find({ "_id": id })

  • db.collection.getDocument(id)

  • db.collection.findOne(id)

Question 8

What does the findOneAndDelete() method do?

  • Deletes all matching documents

  • Finds and returns a document, then deletes it

  • Deletes the first matching document without returning it

  • Deletes a document after replacing it

Question 9

How can you query for documents where a field is missing?

  • { field: { $exists: false } }

  • { field: { $notexists: true } }

  • { field: { $missing: true } }

  • { field: null }

Question 10

Which MongoDB method finds a document and updates it in one step?

  • updateOneAndFind()

  • modifyAndUpdate()

  •  findOneAndUpdate()

  • replaceOneAndFind()

Tags:

There are 10 questions to complete.

Take a part in the ongoing discussion