MongoDB\ChangeStream::next()

For the complete MongoDB documentation index, see www.mongodb.com/docs/llms.txt

MongoDB\ChangeStream::next()

Definition

Advances the change stream and attempts to load the next event.

function next(): void

Note:

Advancing the change stream does not guarantee that there will be a current event to access. You should still call [MongoDB\ChangeStream::valid()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbchangestream-valid.md#mongodb-phpmethod-phpmethod.MongoDB-ChangeStream--valid-- to check for a current event at each step of iteration.

Errors/Exceptions

MongoDB\Driver\Exception\RuntimeException for other errors at the extension level (e.g. connection errors).

See Also

  • [MongoDB\Client::watch()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbclient-watch.md#mongodb-phpmethod-phpmethod.MongoDB-Client--watch--

  • [MongoDB\Collection::watch()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbcollection-watch.md#mongodb-phpmethod-phpmethod.MongoDB-Collection--watch--

  • [MongoDB\Database::watch()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbdatabase-watch.md#mongodb-phpmethod-phpmethod.MongoDB-Database--watch--

  • Iterator::next()

  • [Tailable Cursor Iteration](https://www.mongodb.com/docs/php-library/current/crud/query/cursor.md#std-label-php-tailable-cursor

  • Change Streams documentation in the MongoDB manual