This new method replaces Collection::command() and handles cursor results transparently, guaranteeing to not leave any unfinished cursors hanging around.
Old code
$list= $collection->command('listIndexes, []);
foreach ($list['cursor']['firstBatch'] as $index) {
// Work with index
}
if ($list['cursor']['id']->number() > 0) {
// Handle next batch, either by fetching or by killing the cursor
}
New code
foreach ($collection->run('listIndexes, [])->cursor() as $index) {
// Work with index
}
This new method replaces
Collection::command()
and handles cursor results transparently, guaranteeing to not leave any unfinished cursors hanging around.Old code
New code
Generic handling