Mongodb Certified Developer Associate C100dev · Free Practice Question Medium

Question 12

The following capped collection is given:




What the latest_news collection will look like after the following operation?



  • A
  • B
  • C
  • D
Reveal correct answer

Correct answer: D

A.

This option represents the initial state of the collection before executing the insertOne operation. It does not include the newly inserted document and, therefore, is not the correct answer.

B.

This option includes the initial documents of the collection but does not consider the new document that is being inserted. It does not reflect the outcome of the insertOne operation and, therefore, is not the correct answer.

C.

This option only includes the newly inserted document with the title "TikTok owner ByteDance dissolves its investment arm." However, it fails to consider the capped nature of the collection, which allows a maximum of 3 documents. As per the capped collection settings, the collection should still contain the three most recent documents.

D.

This option represents the correct result after executing the operation db.latest_news.insertOne({...}). The new document with the title "TikTok owner ByteDance dissolves its investment arm" will be added to the capped collection, and as the collection has a maximum size of 10,000 bytes and a maximum of 3 documents, the oldest document (COVID records) will be removed to make room for the new document. Therefore, the resulting collection will include the three most recent documents, with the "COVID records" document being replaced by the "TikTok owner ByteDance dissolves its investment arm" document.

Discussion

Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.

You must be logged in to post a comment.

Preparing For

Your Certification?

255+ certifications
Detailed explanations
Free PDF samples

Has All The Questions You Need