In order to fully initialize a DBClientCursor object, one must first call its constructor and then subsequently call DBClientCursor::init(). If the programmer makes a mistake and fails to call init(), the cursor can silently return no results rather than raising an error. Consider code like this:
This code is incorrect, since it fails to call init(). However, the call to cursor->more() simply returns false rather than throwing or tripping an assertion, so the bug could easily go undetected. We should improve the code to uassert() or possibly invariant() in this scenario.