C100DBA · Question #53
In a collection that contains 100 post documents, what does the following command do? db. posts. find().skip(5).limit(5)
The correct answer is D. Skips the first five documents and returns the next five. db.posts.find().skip(5).limit(5) chains two cursor modifiers: skip(5) moves past the first 5 documents, and limit(5) caps the result at 5 documents - so you get documents 6 through 10, making D correct. Option A is wrong because skip and limit are independent operations that…
Question
In a collection that contains 100 post documents, what does the following command do? db. posts. find().skip(5).limit(5)
Options
- ASkip and limit nullify each other. Hence returning the first five documents
- BLimits the first five documents and then return them in reverse order
- CSkips the first five documents and returns the sixth document five times
- DSkips the first five documents and returns the next five
How the community answered
(42 responses)- A2% (1)
- B2% (1)
- C7% (3)
- D88% (37)
Explanation
db.posts.find().skip(5).limit(5) chains two cursor modifiers: skip(5) moves past the first 5 documents, and limit(5) caps the result at 5 documents - so you get documents 6 through 10, making D correct. Option A is wrong because skip and limit are independent operations that don't cancel each other out. Option B is wrong because limit restricts the count of results returned, not their order. Option C is wrong because limit(5) returns up to 5 distinct documents, not one document repeated five times.
Memory tip: Think of it like a book - skip is the page you open to, and limit is how many pages you read from there. Skip 5, read 5 = pages 6–10.
Topics
Community Discussion
No community discussion yet for this question.