Docs Menu

Docs HomePHP Library Manual

MongoDB\ChangeStream::rewind()

On this page

  • Definition
  • Errors/Exceptions
  • See Also
MongoDB\\ChangeStream::rewind()

Rewinds the change stream and attempts to load the first event.

function rewind(): void

This method should be called at the start of change stream iteration.

Note

Rewinding the change stream does not guarantee that there will be a current event to access. You should still call MongoDB\\ChangeStream::valid() to check for a current event at each step of iteration. After initially rewinding the change stream, MongoDB\\ChangeStream::next() should be used to iterate further.

MongoDB\\Driver\\Exception\\LogicException if this method is called after a call to MongoDB\\ChangeStream::next() (i.e. the underlying MongoDB\\Driver\\Cursor has already been advanced).

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

←  MongoDB\ChangeStream::next()MongoDB\ChangeStream::valid() →