MongoDB\ChangeStream::valid()

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

MongoDB\ChangeStream::valid()

Definition

Returns whether there is a current event in the change stream.

function valid(): boolean

When manually iterating the change stream using Iterator methods, this method should be used to determine if [MongoDB\ChangeStream::current()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbchangestream-current.md#mongodb-phpmethod-phpmethod.MongoDB-ChangeStream--current-- and [MongoDB\ChangeStream::key()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbchangestream-key.md#mongodb-phpmethod-phpmethod.MongoDB-ChangeStream--key-- can be called.

Return Values

A boolean indicating whether there is a current event in the change stream.

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::valid()

  • [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