Mongodb Certified Developer Associate C100dev · Free Practice Question Easy

Question 5

Which cursor method should you use to return the number of documents in the result set?

  • A

    cursor.count()

  • B

    cursor.total()

  • C

    cursor.sum()

  • D

    cursor.explain()

Reveal correct answer

Correct answer: A

A.

The cursor.count() method is used to return the number of documents in the result set. It provides the count of documents that match the query criteria and are returned by the cursor.

B.

The cursor.total() method does not exist in the context of cursor methods in common programming libraries or frameworks. Therefore, it is not the correct answer.

C.

The cursor.sum() method is not suitable for returning the number of documents in the result set. It is typically used for calculating the sum of specific fields within the documents, rather than providing a count.

D.

The cursor.explain() method is used to retrieve information about the execution plan of a query, providing insights into how MongoDB will execute the query. It does not directly return the number of documents in the result set.

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