GoLang MongoDB\Driver\Cursor::isDead

request it (253)
GoLang replacement for PHP's MongoDB\Driver\Cursor::isDead [edit | history]



Do you know a GoLang replacement for PHP's MongoDB\Driver\Cursor::isDead? Write it!

PHP MongoDB\Driver\Cursor::isDead

PHP original manual for MongoDB\Driver\Cursor::isDead [ show | php.net ]

MongoDB\Driver\Cursor::isDead

(mongodb >=1.0.0)

MongoDB\Driver\Cursor::isDeadChecks if the cursor may have additional results

Description

final public bool MongoDB\Driver\Cursor::isDead ( void )

Checks whether the cursor may have additional results available to read. A cursor is initially "alive" but may become "dead" for any of the following reasons:

  • Advancing a non-tailable cursor did not return a document
  • The cursor encountered an error
  • The cursor read its last batch to completion
  • The cursor reached its configured limit
This is primarily useful with tailable cursors.

Parameters

This function has no parameters.

Return Values

Returns TRUE if additional results are not available, and FALSE otherwise.

Errors/Exceptions

Examples

Example #1 MongoDB\Driver\Cursor::isDead() example

<?php

$manager 
= new MongoDB\Driver\Manager("mongodb://localhost:27017");
$query = new MongoDB\Driver\Query([]);

$bulk = new MongoDB\Driver\BulkWrite;
$bulk->insert(['x' => 1]);
$bulk->insert(['x' => 2]);
$bulk->insert(['x' => 3]);
$manager->executeBulkWrite('db.collection'$bulk);

$cursor $manager->executeQuery('db.collection'$query);

$iterator = new IteratorIterator($cursor);

$iterator->rewind();
var_dump($cursor->isDead());

$iterator->next();
var_dump($cursor->isDead());

$iterator->next();
var_dump($cursor->isDead());

$iterator->next();
var_dump($cursor->isDead());

?>

The above example will output:

bool(false)
bool(false)
bool(false)
bool(true)