- Reference >
- Result Classes >
- MongoDB\ChangeStream::current()
MongoDB\ChangeStream::current()
On this page
Definition
-
MongoDB\ChangeStream::current
Returns the current event in the change stream.
The structure of each event document will vary based on the operation type. See Change Events in the MongoDB manual for more information.
Return Values
An array or object for the current event in the change stream, or null
if
there is no current event (i.e. MongoDB\ChangeStream::valid()
returns false
). The return type will depend on the typeMap
option for
MongoDB\Collection::watch()
.
Examples
This example reports events while iterating a change stream.
Assuming that a document was inserted, updated, and deleted while the above script was iterating the change stream, the output would then resemble:
See Also
MongoDB\Collection::watch()
- Iterator::current()
- Tailable Cursor Iteration
- Change Streams documentation in the MongoDB manual
- Change Events documentation in the MongoDB manual