MongoDB\ChangeStream::getCursorId()
For the complete MongoDB documentation index, see www.mongodb.com/docs/llms.txt
MongoDB\ChangeStream::getCursorId()
Definition
Returns the change stream cursor's ID.
function getCursorId(): MongoDB\Driver\CursorId
Return Values
A MongoDB\Driver\CursorId object.
Examples
This example reports the cursor ID for a change stream.
<?php
$uri = 'mongodb://rs1.example.com,rs2.example.com/?replicaSet=myReplicaSet';
$collection = (new MongoDB\Client($uri))->test->inventory;
$changeStream = $collection->watch();
var_dump($changeStream->getCursorId());
The output would then resemble:
object(MongoDB\Driver\CursorId)#5 (1) {
["id"]=>
int(8462642181784669708)
}
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--
